F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Sort

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7201    Accepted Submission(s): 1767


Problem Description
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.
 

Input
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)$.
 

Output
For each test cases, output the smallest $k$.
 

Sample Input
1 5 25 1 2 3 4 5
 

Sample Output
3
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-29 21:55:21, Gzip enabled