33OJ
登录 注册

#P14920. [GESP202512 六级] 道具商店

[GESP202512 六级] 道具商店

Background

Corresponding multiple-choice and true/false questions: https://ti.luogu.com.cn/problemset/1202

Problem Description

There are nn items to choose from in the item shop. The ii-th item can increase the player's attack by aia_i points, and costs cic_i gold coins to buy. Each item can only be bought once. Now you have kk gold coins. How many attack points can you increase at most?

Input Format

The first line contains two positive integers n,kn,k, the number of items and the number of gold coins you have.

In the next nn lines, each line contains two positive integers ai,cia_i,c_i, the number of attack points increased by the item and the number of gold coins needed to buy it.

Output Format

Output a single line with an integer, the maximum number of attack points that can be increased.

3 5
99 1
33 2
11 3
132
4 100
10 1
20 11
40 33
100 99
110

Hint

For 60%60\% of the test data, it is guaranteed that 1≤k≤5001\le k\le 500 and 1≤ci≤5001\le c_i\le 500.

For all the test data, it is guaranteed that 1≤n≤5001\le n\le 500, 1≤k≤1091 \le k\le 10^9, 1≤ai≤5001\le a_i\le 500, and 1≤ci≤1091\le c_i\le 10^9.

Translated by QwenWork