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
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
Constraints
Subtask 1 [40%]
Subtask 2 [30%]
Subtask 3 [30%]
No additional constraints.
Input Specification
The first line contains
The next
Output Specification
Output the maximum total tastiness after swapping up to
Sample Input
3 5 1
2 4
3 3
8 9
Sample Output
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
Comments