#Lutece3309. The Circle Game
The Circle Game
Description
And the seasons they go round and round
And the painted ponies go up and down
We're captive on the carousel of time
We can't return, we can only look behind from where we came
And go round and round and round in the circle game...-- Joni Mitchell, The Circle Game
One day, vv123 thought of the days when he played circle game with his classmates in PE class, when he was just an elementary school student.
There are ( is even) kids forming a circle hand by hand, the strength of the kids are respectively. vv123 wants to rearrange the kids in the circle, so that the circle is firmest.
Suppose that the villain can only attack half the circle at a time, and it will obviously attack the weakest part of the circle. So, we define the firmness of the circle as the smallest sum of any consecutive kids' strength.
For the given , what's the maximum firmness that can be achieved?
Input
An integer (). It is guaranteed that is even.
Output
An integer, denoting the maximum firmness that can be achieved.
Samples
4
4
6
10
Note
In the first example, , there are ways to form the circle:
- , the firmness is .
- , the firmness is .
- , the firmness is .
- , the firmness is .
- , the firmness is .
- , the firmness is .
So, the maximum firmness that can be achieved is .
In the second example, there are ways to form the circle. The maximum firmness that can be achieved is , and one possible way to achieve this is .
Resources
电子科技大学第十三届 ACM 趣味程序设计竞赛