Schools
InterviewTime limit2sMemory limit256 MB
Choose M cities for music schools and S other cities for sports schools to maximize the total number of attending students.
Problem
To support education, the administrator of a state decided to open exactly music schools and exactly sports schools. The state has different cities, and for every city you know how many students would attend a music school and how many would attend a sports school. The administrator never opens more than one school in a city, so each city gets one music school, one sports school, or no school at all.
If a music school opens in city , then students attend it. If a sports school opens in city , then students attend it.
Make the plan that maximizes the total number of students attending the new schools, and report that total.
Input
The first line contains the number of cities , the number of music schools to open , and the number of sports schools to open , separated by spaces (, , ).
The -th of the next lines contains two integers and (, ). is the number of students in city who want to study in a music school, and is the number who want to study in a sports school.
Output
Print one integer, the total number of students attending the new schools in an optimal plan.