#P4040. [AHOI2014/JSOI2014] 宅男计划
[AHOI2014/JSOI2014] 宅男计划
Description
There are types of food, numbered from to . The -th type of food has a fixed price and a shelf life . The -th type expires after days. JYY will not eat expired food.
For example, if JYY orders a food with a shelf life of day today, then JYY must eat it today or tomorrow; otherwise, this food can no longer be eaten. The shelf life can be days, in which case the food must be eaten on the day of purchase.
JYY currently has yuan. Each time he places a takeout order, he must additionally pay a delivery fee of yuan.
The delivery person is strong and can instantly bring JYY arbitrarily many portions of food in one order. JYY wants to know, while ensuring that he can eat at least one unexpired takeout meal every day, for how many days at most can he stay at home.
Input Format
The first line contains three integers, representing .
Lines to each contain two integers; in line , the integers denote the price and the shelf life of the -th type of food.
Output Format
Output a single integer in one line, representing the maximum number of days JYY can stay at home.
32 5 2
5 0
10 2
3
Hint
Explanation of Sample Input/Output 1
JYY’s best strategy is:
- On day 1, buy one portion of food and one portion of food , and eat one portion of food .
- On day 2, eat one portion of food .
- On day 3, buy one portion of food and eat it.
Constraints
For all test points, it is guaranteed that , , .
Translated by ChatGPT 5
京公网安备 11011102002149号