AmazonOA #284
Minimum Days to Deliver Parcels
Estimated EasyJudge-ready
Topics (AI-labelled)Hashing
Each day, choose a positive integer x and ship exactly x parcels from every center that still has parcels. x cannot exceed the current remaining amount of any non-empty center, and empty centers do not take part. Find the minimum number of days to ship all parcels. If everything is 0 at the start, the answer is 0 days.
Input
The first line contains n and the second line contains parcels. 1≤n≤1000000, 0≤parcels[i]≤10^9; the original million-sized range is kept.
Output
Output a single integer, the answer.
Example 1
Input:
5
2 3 4 3 3
Output:
3
Example 2
Input:
3
3 3 3
Output:
1
Example 3
Input:
2
0 0
Output:
0
Example notes
The answers are 3, 1 and 0 respectively. In the first example you can ship 2, 1 and then 1 parcels from every non-empty center.
Editorial
Loading solution…