#P14635. [NOIP2025] 糖果店
[NOIP2025] 糖果店
Problem Description
Little X has opened a candy shop selling kinds of candies, with an unlimited number of candies of each kind. For different kinds of candies, Little X uses different promotion strategies. Specifically, for the -th kind of candy (), the price of the first candy is yuan, the price of the second candy is yuan, the price of the third candy is yuan again, the price of the fourth candy is yuan, and so on.
Little R has brought yuan to buy candies. Little R does not care about the kinds of candies and only wants to get as many candies as possible. You need to help Little R find the maximum number of candies that can be bought with yuan.
Input Format
The first line of the input contains two positive integers , denoting the number of kinds of candies and the amount of money Little R has.
The -th line of the input () contains two positive integers , denoting the price of an odd-numbered candy and the price of an even-numbered candy when buying the -th kind of candy respectively.
Output Format
Output one line with one non-negative integer, denoting the maximum number of candies that can be bought with yuan.
2 10
4 1
3 3
4
3 15
1 7
2 3
3 1
8
Hint
Sample 1 Explanation
Little R can buy candies of the first kind, spending yuan in total.
Sample 2 Explanation
Little R can buy candy of the first kind, candy of the second kind and candies of the third kind, spending yuan in total.
Sample 3
See candy/candy3.in and candy/candy3.ans in the contestant directory.
This sample satisfies the constraints of test .
Sample 4
See candy/candy4.in and candy/candy4.ans in the contestant directory.
This sample satisfies the constraints of tests .
Sample 5
See candy/candy5.in and candy/candy5.ans in the contestant directory.
This sample satisfies the constraints of tests .
Sample 6
See candy/candy6.in and candy/candy6.ans in the contestant directory.
This sample satisfies the constraints of test .
Sample 7
See candy/candy7.in and candy/candy7.ans in the contestant directory.
This sample satisfies the constraints of tests .
Constraints
For all testdata, we have:
- ;
- ;
- For all , .
::cute-table{tuack}
| Test | Special property | ||
|---|---|---|---|
| None | |||
| ^ | |||
| ^ | |||
| A | |||
| ^ | B | ||
| None | |||
| A | |||
| ^ | B | ||
| None | |||
| A | |||
| ^ | ^ | B | |
| None | |||
| ^ | |||
Special property A: for all , .
Special property B: for all , .
Translated by QwenWork