SnowflakeOA #13
Cross the Threshold
估计中等可在线判题
考点(AI 标注)二分查找
The final energy of each particle is max(energy−barrier,0). Find the largest non-negative integer barrier such that the total energy is ≥th. The original total energy is guaranteed to be ≥th.
输入格式
The first line contains n th, and the second line contains n energies. 2≤n≤100000, 1≤energy≤10⁹, 1≤th≤10¹⁴.
输出格式
Output the single integer required by the problem.
样例 1
输入:
5 9
4 8 7 2 1
输出:
3
样例 2
输入:
4 8
5 2 13 10
输出:
7
样例 3
输入:
3 6
3 9 7
输出:
5
样例说明
The answers to the three public examples are, in order: 3; 7; 5. All examples have been verified by independent small-scale enumeration or state search.