QOJ.ac

QOJ

시간 제한: 2 s 메모리 제한: 256 MB 총점: 100 해킹 가능 ✓

#16895. Special Prize

통계

$N$ students participated in an art competition. One organizer and one judge determine the award winners, and the method for determining the winners is as follows:

  1. The organizer and the judge each score all students' works. Both individuals do not give the same score to two different works when scoring.
  2. The organizer selects $M$ students to receive a special award.
  3. The judge selects the $K$ works with the highest scores among those that did not receive a special award, and awards the main prize to the corresponding $K$ students.

The organizer wants to maximize the sum of the scores they gave to the works of the students who receive an award, regardless of the type of award. Find the maximum possible sum.

Input

The first line contains the total number of students $N$, the number of students to receive a special award $M$, and the number of students to receive a main prize $K$, separated by spaces. ($2 \le N \le 2 \times 10^5$; $1 \le M, K \le N - 1$; $M + K \le N$)

From the second line, $N$ lines follow, each containing the score $a_i$ given by the organizer and the score $b_i$ given by the judge for each work, separated by spaces. ($0 \le a_i, b_i \le 10^9$) All scores are integers, and for $i \neq j$, the conditions $a_i \neq a_j$ and $b_i \neq b_j$ are satisfied.

Output

Output the maximum sum of the scores given by the organizer for the works of the $M + K$ students who receive an award.

Examples

Input 1

7 2 3
4 7
7 8
2 1
9 3
6 0
10 4
3 6

Output 1

33

Note

If the organizer selects the first and fourth students to receive the special award, the judge will award the second, sixth, and seventh students based on the scores the judge gave. In this case, the sum of the scores given by the organizer for the 5 students who received an award is 33, and it can be proven that this is the maximum possible value.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.