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

uvalive 6609 - Minimal Subarray Length(离散化+树状数组)

题意:给出n个数,求加和大于x的最短区间的区间长度。 如果前i个数字和为y,那么如果前j数字的和小于等于y-x,那么i-j就是一种可能的情况,我们对于所有的i找出前面最大的j就可以了,因为数据量比较大,用树状数组来处理前n项的最大值,但是每个数字又可能比较大,所以先离散化处理一下。 #include <iostream>#include <cstring>#include <cstdi