当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5884:Sort

题目描述
Recently, Bob has just learnt a naive sorting algorithm: merge sort. Now, Bob receives a task from Alice.
Alice will give Bob $N$ sorted sequences, and the $i$-th sequence includes $a_i$ elements. Bob need to merge all of these sequences. He can write a program, which can merge no more than $k$ sequences in one time. The cost of a merging operation is the sum of the length of these sequences. Unfortunately, Alice allows this program to use no more than $T$ cost. So Bob wants to know the smallest $k$ to make the program complete in time.
输入解释
The first line of input contains an integer $t_0$, the number of test cases. $t_0$ test cases follow.
For each test case, the first line consists two integers $N~(2 \leq N \leq 100000)$ and $T~(\sum_{i=1}^{N}a_i < T < 2^{31}
)$.
In the next line there are $N$ integers $a_1, a_2, a_3, ... , a_N(\forall i, 0 \leq a_i \leq 1000)$.
输出解释
For each test cases, output the smallest $k$.
输入样例
1
5 25
1 2 3 4 5
输出样例
3
来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5884

最后修改于 2020-10-25T23:26:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/1000MS(Java/Others) 32768/32768K(Java/Others)