Hiring
Time limit1sMemory limit128 MB
Choose a real wage coefficient k and a subset of workers so that each hired worker's pay Q_i*k meets their minimum S_i and the total pay stays within budget W, maximizing the subset size.
- Level
Hard8 of 10
- Topics
- Sorting, Greedy, Binary search, Math
- Solved
- No attempts yet
Problem
Jaehyun is hiring workers to build a skyscraper called the "Second Apple Tower". There are applicants numbered from to . Worker has a minimum wage and a construction-certificate level , so hiring worker requires paying them a wage of at least .
To promote construction certificates, the government made a rule that every hired worker's wage must be directly proportional to their certificate level. That is, once a single real coefficient is chosen, each hired worker is paid exactly . Wages may be real numbers, not just integers. Because every hired worker must satisfy , the coefficient must be chosen large enough to meet the minimum-wage requirement of all hired workers.
Jaehyun has dollars. He does not care about certificate levels and only wants to finish the building as fast as possible, so he wants to hire as many workers as possible while keeping the total wage he pays at most . Find the maximum number of workers he can hire.
Input
The following data is given on standard input.
- The first line contains the number of workers and the amount of money , separated by a space.
- Each of the next lines contains the minimum wage and the certificate level of worker , separated by a space (the -th such line describes worker ).
Output
Print a single integer: the maximum number of workers that can be hired within the budget.
Constraints
- (number of applicants)
- (minimum wage of worker )
- (certificate level of worker )
- (amount of money available)
- All numbers given in the input are integers.