AmazonOA #229
Compute Least Truck Count
Estimated MediumJudge-ready
Topics (AI-labelled)Binary SearchBits & MathGreedy
Each category has items[i] packages that can be assigned independently. Each truck carries at most C packages, and at most L packages of the same category. All packages must be shipped; find the minimum number of trucks. A category does not have to ride together in a single truck. With no packages at all, 0 trucks are needed.
Input
The first line contains n C L; the second line contains the count of each category. The original text had no numeric bounds; this site uses 1≤n≤200000, 0≤count≤10^9, 1≤C,L≤10^9.
Output
Output a single integer, the answer.
Example 1
Input:
2 3 2
2 4
Output:
2
Example 2
Input:
3 3 3
4 4 3
Output:
4
Example 3
Input:
1 100 3
10
Output:
4
Example notes
The answers are 2, 4 and 4. The third example is determined by the per-truck limit for a single category.
Editorial
Loading solution…