The winner of a student competition received internship offers from two universities.
While preparing his plans of study, he learned the teaching quality rating of each discipline at these universities.
The curriculum of the first university consists of a sequence of
The student has the option of making a plan of study at the first university to take some sequence of disciplines at curriculum positions
It does not make sense to study the same discipline twice at different universities, so
all the disciplines in the two chosen plans of study must be different.
Write a program to determine the highest possible sum of ratings of the studied disciplines, given the student makes an optimal study plan.
Subtask # | Score | Constraints |
---|---|---|
1 | 10 | |
2 | 10 | |
3 | 10 | |
4 | 10 | |
5 | 10 | |
6 | 5 | |
7 | 5 | |
8 | 10 | |
9 | 10 | |
10 | 10 | |
9 | 10 | No additional constraints |
The first line of input contains integers
The second line of input contains
The third line of input contains
The fourth line of input contains
The fifth line of input contains
The first line of output should contain an integer
The second line of output should contain two integers
The third line of output should contain two integers
If there are several possible answers, you may output any one of them.
Sample Input 1 | Sample Output 1 |
7 5
|
39
|
The optimal solution is to take the courses described in the output, yielding a sum of ratings of
Sample Input 2 | Sample Output 2 |
2 3
|
34
|
In this testcase, the first and third disciplines at the second university are rated so highly compared to the corresponding disciplines at the first university, that the optimal choicen is to take the entire internship at the second university and forgo an internship at the first university.
Sample Input 3 | Sample Output 3 |
3 3
|
19
|
Subtask | Score |
---|---|
1 | 10 |
2 | 10 |
3 | 10 |
4 | 10 |
5 | 10 |
6 | 5 |
7 | 5 |
8 | 10 |
9 | 10 |
10 | 10 |
11 | 10 |
12 | 0 |