CF808E.Selling Souvenirs
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
After several latest reforms many tourists are planning to visit Berland, and Berland people understood that it's an opportunity to earn money and changed their jobs to attract tourists. Petya, for example, left the IT corporation he had been working for and started to sell souvenirs at the market.
This morning, as usual, Petya will come to the market. Petya has n different souvenirs to sell; _i_th souvenir is characterised by its weight w__i and cost c__i. Petya knows that he might not be able to carry all the souvenirs to the market. So Petya wants to choose a subset of souvenirs such that its total weight is not greater than m, and total cost is maximum possible.
Help Petya to determine maximum possible total cost.
在最近的几次改革之后,许多游客计划前往贝尔兰德旅游,而贝尔兰德人意识到这是一个赚钱的机会,纷纷转行以吸引游客。例如,佩佳就离开了他一直工作的IT公司,开始在集市上售卖纪念品。
今天早上,和往常一样,佩佳将前往集市。佩佳有 n 种不同的纪念品可供出售;其中第 i 种纪念品的重量为 wi,价格为 ci。佩佳知道,他可能无法将所有纪念品都带到集市上。因此,佩佳希望从中选出一个子集,使得该子集的总重量不超过 m,且总价格尽可能大。
请帮助佩佳确定可能的最大总价格。
输入格式
The first line contains two integers n and m (1 ≤ n ≤ 100000, 1 ≤ m ≤ 300000) — the number of Petya's souvenirs and total weight that he can carry to the market.
Then n lines follow. _i_th line contains two integers w__i and c__i (1 ≤ w__i ≤ 3, 1 ≤ c__i ≤ 109) — the weight and the cost of _i_th souvenir.
第一行包含两个整数 n 和 m(1≤n≤100000,1≤m≤300000)——分别表示 Petya 的纪念品数量以及他能带到市场的总重量上限。
接下来是 n 行。第 i 行包含两个整数 wi 和 ci(1≤wi≤3,1≤ci≤109)——分别表示第 i 个纪念品的重量和价值。
输出格式
Print one number — maximum possible total cost of souvenirs that Petya can carry to the market.
输出一个数字——Petya 能带到市场的纪念品的总价值的最大可能值。
输入输出样例
输入#1
1 1 2 1
输出#1
0
输入#2
2 2 1 3 2 2
输出#2
3
输入#3
4 3 3 10 2 7 2 8 1 1
输出#3
10
输入解题思路,AI测评打分。不知道怎么写?