DMOPC '22 Contest 3 P4 - Sketchy Cereal

View as PDF

Submit solution


Points: 30 (partial)
Time limit: 1.5s
Memory limit: 256M

Author:
Problem type

As a broke university student who finally has time to go shopping for the first time in months, you decide to go on a cereal haul as motivation to actually eat breakfast next semester. At the supermarket, you see N boxes of cereal, the i-th having a price tag of ci dollars and ti tastiness. You have a budget of C dollars, and would like to maximize the total tastiness of the cereal you buy.

Money is tight though, and sometimes you have to resort to some morally questionable tricks up your sleeve to maximize the efficiency of your spending. While shopping for the cereal, you have time to sneakily swap the price tags of up to K pairs of cereal boxes, one pair after another, without getting caught. Given these conditions, what is the maximum total tastiness you can achieve?

Constraints

1N103

1C,ci2×104

1ti109

0KN

Subtask 1 [40%]

1N200

0K5

Subtask 2 [30%]

1N200

0K50

Subtask 3 [30%]

No additional constraints.

Input Specification

The first line contains 3 integers N, C, and K.

The next N lines each contain 2 integers ci and ti.

Output Specification

Output the maximum total tastiness after swapping up to K pairs of price tags.

Sample Input

Copy
3 5 1
2 4
3 3
8 9

Sample Output

Copy
13

Explanation for Sample

We can swap the price tags of the second and third cereal boxes, then buy the first and the third boxes for a total tastiness of 13.


Comments

There are no comments at the moment.