P10771 [NOISG 2021 Qualification] Competition

Description

You are a teacher with $n$ students. Each student has a Physics score $A_i$ and a Biology score $B_i$. You need to choose $a$ students to participate in the Physics competition and $b$ students to participate in the Biology competition. Each student must participate in exactly one competition. Define your school's strength value as the sum of the Physics scores of those who participate in the Physics competition and the Biology scores of those who participate in the Biology competition. Find the maximum possible strength value.

Input Format

The first line contains three integers $n, a, b$. The second line contains $n$ integers $A_i$. The third line contains $n$ integers $B_i$.

Output Format

Output one integer in one line: the maximum strength value.

Explanation/Hint

#### Explanation for Sample 1 The 1st and 3rd students participate in the Biology competition, and the 2nd student participates in the Physics competition. #### Constraints **This problem uses bundled testdata.** Subtask0 is the sample. Subtask1 (29 pts): $n \leq 20$. Subtask2 (22 pts): it is guaranteed that all $B_i=0$. Subtask3 (49 pts): no special constraints. It is guaranteed that $1 \leq n \leq 10^5$, $0 \leq a,b \leq n$, $a+b=n$, and $0 \leq A_i,B_i \leq 10^4$. Translated by ChatGPT 5