AmazonOA #228
Get Minimum Dock Bays
估计中等可在线判题
Trucks must start unloading in input order, and a free dock immediately takes the next truck; trucks that start at the same time are assigned in input order. All trucks must finish within time T; find the minimum number of docks. Trucks cannot be reordered.
输入格式
The first line contains n T; the second line contains each truck's duration. 1≤n≤50000, 1≤T≤10^15, 1≤duration≤min(T,10^9). The source has a note about reading the upper bound of T; this site explicitly uses 10^15.
输出格式
Output a single integer, the answer.
样例 1
输入:
5 8
3 4 3 2 3
输出:
3
样例 2
输入:
3 7
2 3 1
输出:
1
样例 3
输入:
2 2
2 2
输出:
2
样例说明
The answers are 3, 1 and 2. In the first example two docks would need 9 minutes, which does not meet the limit of 8.