AmazonOA #258
Max Batches For Shipment
估计困难可在线判题
Each category has inventory[i] items. Each batch uses at most one item per category, and each batch must contain strictly more items than the previous one; each item can be used at most once, and leftovers are allowed. Find the maximum number of batches.
输入格式
The first line contains n; the second line contains the inventories. The original text had no numeric bounds; this site uses 1≤n≤200000, 0≤inventory[i]≤10^9.
输出格式
Output a single integer, the answer.
样例 1
输入:
5
2 3 1 4 2
输出:
4
样例 2
输入:
3
100 1 1
输出:
2
样例 3
输入:
3
0 0 0
输出:
0
样例说明
The answers are 4, 2 and 0. Even with a large total, the two of the three categories that have only one item each cannot both supply the second and the third batches.