|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||512 MB||6||5||5||83.333%|
You are Nilan, teaching a class of n students. Recently, each student sat for two examinations — Physics and Biology. The scores of the i-th student in Physics and Biology are denoted by A[i] and B[i] respectively. Each score is a non-negative integer not exceeding 10000, i.e. 0 ≤ A[i], B[i] ≤ 10000, ∀i ∈ [1, n].
Based on their results, you are to select a and b students to participate in the Physics and Biology categories of a Science competition respectively. To give all students a chance to represent their school, each student must be enrolled in exactly one of the categories.
Naturally, the school wants to maximise its chances of winning by sending the strongest team possible. This is achieved when the sum of Physics scores of the a Physics students combined with the sum of Biology scores of the b Biology students is maximised.
As their teacher, determine the maximum possible combined score of the Physics and Biology teams!
Your program must read from standard input.
The first line of the input contains 3 integers n, a and b denoting the total number of students, the size of the Physics team and the size of the Biology team. It is guaranteed that a + b = n i.e. all students take part as either a Physics or a Biology competitor.
2 lines will follow. The first line contains n integers, i.e A, A, . . . , A[n]. The second line contains n integers, i.e B, B, . . . , B[n].
Your program must print to standard output.
The output should contain a single integer on a single line, the maximum combined sum of all the Physics scores of the Physics team, and the Biology scores of the Biology team.
1 ≤ n ≤ 20
B[i] = 0, ∀i ∈ [1, n]
3 1 2 5 3 4 7 1 4
The optimal way of choosing the school team is to assign the second student to the Physics team and the first and third students to the Biology team. The combined Physics score of the Physics team is 3, while the combined Biology score of the Biology team is 7 + 4 = 11. The total score is thus 3 + 11 = 14. It is impossible to achieve a total score higher than 14, thus 14 is our answer.
5 3 2 5 6 6 5 1 0 0 0 0 0
The optimal way of choosing the school team is to assign the first three students to the Physics team and the last two students to the Biology team. The combined Physics score of the Physics team is 5 + 6 + 6 = 17, while the combined Biology score of the Biology team is 0 + 0 = 0. The total score is thus 17 + 0 = 17. It is impossible to achieve a total score higher than 17, thus 17 is our answer.