33OJ
登录 注册

#P14635. [NOIP2025] 糖果店

    ID: 16466 远端评测题 1000ms 512MiB 尝试: 43 已通过: 4 显示难度普及 上传者: 标签>贪心二分2025NOIP 提高组O2优化排序

[NOIP2025] 糖果店

Problem Description

Little X has opened a candy shop selling nn 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 ii-th kind of candy (1≤i≤n1 \le i \le n), the price of the first candy is xix_i yuan, the price of the second candy is yiy_i yuan, the price of the third candy is xix_i yuan again, the price of the fourth candy is yiy_i yuan, and so on.

Little R has brought mm 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 mm yuan.

Input Format

The first line of the input contains two positive integers n,mn, m, denoting the number of kinds of candies and the amount of money Little R has.

The (i+1)(i+1)-th line of the input (1≤i≤n1 \le i \le n) contains two positive integers xi,yix_i, y_i, denoting the price of an odd-numbered candy and the price of an even-numbered candy when buying the ii-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 mm 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 44 candies of the first kind, spending 4+1+4+1=104 + 1 + 4 + 1 = 10 yuan in total.

Sample 2 Explanation

Little R can buy 11 candy of the first kind, 11 candy of the second kind and 66 candies of the third kind, spending 1+2+12=151 + 2 + 12 = 15 yuan in total.

Sample 3

See candy/candy3.in and candy/candy3.ans in the contestant directory.

This sample satisfies the constraints of test 66.

Sample 4

See candy/candy4.in and candy/candy4.ans in the contestant directory.

This sample satisfies the constraints of tests 8,98,9.

Sample 5

See candy/candy5.in and candy/candy5.ans in the contestant directory.

This sample satisfies the constraints of tests 11,1211,12.

Sample 6

See candy/candy6.in and candy/candy6.ans in the contestant directory.

This sample satisfies the constraints of test 1313.

Sample 7

See candy/candy7.in and candy/candy7.ans in the contestant directory.

This sample satisfies the constraints of tests 17,1817,18.

Constraints

For all testdata, we have:

  • 1≤n≤1051 \le n \le 10^5;
  • 1≤m≤10181 \le m \le 10^{18};
  • For all 1≤i≤n1 \le i \le n, 1≤xi,yi≤1091 \le x_i, y_i \le 10^9.

::cute-table{tuack}

Test n≤n \le m≤m \le Special property
11 1010 None
2,32,3 22 2020 ^
4,54,5 1010 ^
66 10210^2 A
77 ^ B
8,98,9 None
1010 10310^3 10410^4 A
11,1211,12 ^ B
1313 None
1414 10510^5 10910^9 A
15,1615,16 ^ ^ B
17,1817,18 None
19,2019,20 101810^{18} ^

Special property A: for all 1≤i≤n1 \le i \le n, xi=yix_i = y_i.

Special property B: for all 1≤i≤n1 \le i \le n, xi≥yix_i \ge y_i.

Translated by QwenWork