| UTPC Contest 09-08-23 Div. 1 |
|---|
| Закончено |
Ivan the Iguana has a strong craving for eggs. He particularly enjoys having his eggs either scrambled or fried.
Today's dinner consists of $$$N$$$ eggs.
Ivan has three options for each egg: fry it, scramble it, or not eat it at all. Ivan's appetite permits him to eat a maximum of $$$F$$$ fried eggs and $$$S$$$ scrambled eggs. The $$$i^{th}$$$ egg will give Ivan a satisfaction level of $$$f_i$$$ if fried and $$$s_i$$$ if scrambled. Ivan initially starts at a satisfaction level of $$$0$$$.
Please find the maximum amount of satisfaction that Ivan can gain from eating his eggs if he optimally picks which eggs are scrambled and which are fried.
$$$\textit{Note}: $$$ Ivan can eat less than $$$F$$$ fried eggs and $$$S$$$ scrambled eggs if he can have greater satisfaction doing so.
The first line of input contains three integers: $$$N \space F \space S$$$, the total number of eggs, the maximum number of fried eggs Ivan can eat, and the maximum number of scrambled eggs Ivan can eat. $$$(1 \leq N \leq 10,000; 0 \leq F+S \leq 100)$$$
The next $$$N$$$ lines of input contain two integers: $$$f_i \space s_i$$$, the satisfaction level of the $$$i^{th}$$$ egg when fried and scrambled respectively. $$$(-10^9 \lt f_i, s_i \lt 10^9)$$$
Please output 1 integer, the maximum amount of satisfaction that Ivan can gain from eating his eggs.
5 1 2 3 8 5 6 7 7 4 5 6 2
21
4 0 1 100 -5 5 20 -6 15 30 30
30
| Название |
|---|


