HDU-6609 Find the answer (权值线段树)

2024-01-08 14:08
文章标签 find hdu 线段 answer 权值 6609

本文主要是介绍HDU-6609 Find the answer (权值线段树),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 

 

 

题目:

Given a sequence of n integers called W and an integer m. For each i (1 <= i <= n), you can choose some elements WkWk (1 <= k < i), and change them to zero to make ∑ij=1∑j=1iWjWj<=m. So what's the minimum number of chosen elements to meet the requirements above?.

Input

The first line contains an integer Q --- the number of test cases. 
For each test case: 
The first line contains two integers n and m --- n represents the number of elemens in sequence W and m is as described above. 
The second line contains n integers, which means the sequence W. 

1 <= Q <= 15 
1 <= n <= 2*105105 
1 <= m <= 109109 
For each i, 1 <= WiWi <= m

Output

For each test case, you should output n integers in one line: i-th integer means the minimum num

这篇关于HDU-6609 Find the answer (权值线段树)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/583714

相关文章

上海邀请赛 A题目 HDU 5236(dp)

先求出没有ctrl+s的时候构造长度为i的期望f[i] 。然后枚举保存的次数,求出最小即可。 #include<cstdio>#include<cstdio>#include<cmath>#include<queue>#include<stack>#include<string>#include<cstring>#include<iostream>#include<map>

hdu 2586 树上点对最近距离 (lca)

,只要知道dis[i][j]=dis[i][root]+dis[j][root]-2*dis[Lca(i,j)][root].   其中root为树的根节点,LCA(i,j)为i,j的最近公共祖先。 所以我们先把所有的询问储存下来,然后离线直接查询。复杂度是o(n+q)的。 VIE #include<cstdio>#include<algorithm>#include<i

【Linux系列】find命令使用与用法详解

💝💝💝欢迎来到我的博客,很高兴能够在这里和您见面!希望您在这里可以感受到一份轻松愉快的氛围,不仅可以获得有趣的内容和知识,也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学习,不断总结,共同进步,活到老学到老导航 檀越剑指大厂系列:全面总结 java 核心技术,jvm,并发编程 redis,kafka,Spring,微服务等常用开发工具系列:常用的开发工具,IDEA,M

Leetcode 3195. Find the Minimum Area to Cover All Ones I

Leetcode 3195. Find the Minimum Area to Cover All Ones I 1. 解题思路2. 代码实现 题目链接:3195. Find the Minimum Area to Cover All Ones I 1. 解题思路 这一题还是挺简单的,只要找到所有1所在的元素的上下左右4个边界,作为目标矩形的四个边即可。 2. 代码实现 给出python

「Debug R」报错unable to find an inherited method for function是如何产生的

在一个群里看到这样一条报错,截图如下: 报错信息 当然这种问题解决起来也很快,无非就是把报错信息复制出来放在搜索引擎上,只不过你要挑选合适的搜索引擎。 百度 谷歌 必应 解决方案就是用dplyr::select。 虽然报错解决了,但是我还想着要重复出这个报错。因为只有能重复出报错,才能证明你不是运气好才解

线段树单点修改的应用

思路:对初始状态进行建树,然后这题就相当于查询第一个合法的位置,并且对其值进行修改,整个题目要求维护的是区间最大值,很显然可以使用线段树。 #include <bits/stdc++.h>using namespace std;const int N = 2e6 + 5;typedef long long ll;typedef pair<ll, ll> pll;typedef arra

HDU_1013

这个题目尤其需要注意的是开始输入的时候的数的大小,开始输入时有可能非常的大超过了长整型的范围,所以不能开始用整形来存放输入的,,就是开始的时候没有注意到这个问题所以开始的时候一直没有AC,后来就是用一个数组接收输入,然后在经过第一步转化之后就可以用一个整数来装了 #include <iostream>#include <stdlib.h>#include <string>usin

[leetcode] 515. Find Largest Value in Each Tree Row

Find Largest Value in Each Tree Row 描述 You need to find the largest value in each row of a binary tree. Example: Input: 1/ \3 2/ \ \ 5 3 9 Output: [1, 3, 9] 我的代码 简单的dfs。 要使

最长回文子串(百度笔试题和hdu 3068)

版权所有。所有权利保留。 欢迎转载,转载时请注明出处: http://blog.csdn.net/xiaofei_it/article/details/17123559 求一个字符串的最长回文子串。注意子串是连续的,子序列是不连续的。对于最长回文子序列,要用动态规划解,具体请看: http://blog.csdn.net/xiaofei_it/article/details/1

杭电ACM hdu 2110 Crisis of HDU 解题报告(母函数)

Problem Description 话说上回讲到HDU大战东洋小苟,结果自然是中方大胜,这一战也使得海东集团在全球同行业中的地位更加巩固。随着集团的发展,很多创业时期的元老逐步功成身退,先是8600移民海外,然后是linle夫妇退隐山林,逐渐的,最初众多的元老只剩下XHD夫妇和Wiskey三人了。 到了2020年,因为扩张过度加上老鼠数量逐年减少,公司的发展遇到了前所未有的危机,此时集团已经