#P7176. [COCI 2014/2015 #4] PRIPREME
[COCI 2014/2015 #4] PRIPREME
Description
Ante and Goran are preparing teams. Each of them has one algorithm that needs to be explained to all teams.
Of course, they cannot both explain to the same team at the same time, and neither of them can explain to multiple teams at the same time.
Given the time needed to explain to each team, determine the minimum total time required.
Input Format
The first line contains an integer , the number of teams.
The next line contains space-separated integers , where is the time needed to explain to team .
Output Format
Output a single line: the minimum total time required.
3
2 2 2
6
3
4 1 2
8
4
1 3 2 1
7
Hint
Explanation for Sample 1
Each team needs units of time to understand and implement an algorithm. The following is one feasible teaching plan.
| Ante | Goran | Time |
|---|---|---|
| Team 1 | Team 2 | |
| Team 2 | Team 3 | |
| Team 3 | Team 1 | |
| All finished | ||
Explanation for Sample 2
One optimal schedule is that Ante teaches teams in order, but there is a unit time pause at . Goran will teach teams in order.
Constraints
- For of the testdata, .
- For of the testdata, .
For all valid , .
Notes
This problem is translated from COCI2014-2015 CONTEST #4 T3 PRIPREME.
Translated by ChatGPT 5
京公网安备 11011102002149号