Process Consultant Seok
Time limit1sMemory limit512 MB
Gifts are assigned in order to the currently least loaded of K lines; find the smallest K so the maximum line load is at most X.
- Level
Medium7 of 10
- Topics
- Greedy, Binary search, Implementation, Simulation
- Solved
- No attempts yet
Problem
After a string of successful startups, CEO Ryu Jinguk has decided to build a factory that produces custom gifts. There are currently custom gift orders, and each custom gift has a fixed production time. The orders are numbered from to , and the production follows these rules.
- If there are production lines in total, they are numbered from to .
- The usage time of a production line is the sum of the production times of the custom gifts assigned to it.
- Gift is assigned, after gifts through have been assigned, to one of the production lines with the smallest usage time.
At most hours remain until all custom gifts must be finished, but the number of production lines has not been decided yet. CEO Ryu Jinguk asked the top authority in the field, Process Consultant Seok, for help. Process Consultant Seok wants to minimize the number of production lines in order to spend as little as possible. Help Seok compute the minimum number of production lines needed.
Input
The first line gives the number of custom gift orders and the time remaining until production must finish , separated by a space.
The second line gives the production time needed for gifts through , in order. The unit is 'hour'.
Output
Print the minimum number of production lines needed to produce all gifts within hours.
Constraints
- , is a natural number.
- , is a natural number.
- the production time of each gift , and every time is a natural number.