cswork / OA打开练习工作台

AmazonOA #163

Find Maximum Number of Batches

估计困难可在线判题

考点(AI 标注)贪心调度位运算

Each category has a given quantity. Each batch contains at most 1 item of each category, batch sizes are strictly increasing, items cannot be reused, and leftovers are allowed. Find the maximum number of batches.

输入格式

The first line contains n, and the second line contains n quantities. This site sets 1≤n≤100000 and quantities in 0..10^9.

输出格式

Output a single integer answer.

样例 1

输入:

5
2 3 4 1 2

输出:

4

样例 2

输入:

1
100

输出:

1

样例 3

输入:

3
1 1 1

输出:

2

样例说明

Example 1: you can form four batches of sizes 1, 2, 3 and 4; a fifth batch would need 15 items cumulatively, but there are only 12. Example 2: there is only one category, so each batch has at most 1 item, giving at most 1 batch. Example 3: three items of different categories can be split into two batches of 1 and 2 items, so the answer is 2.