luogu#P4734. [BalticOI 2015] Hacker
[BalticOI 2015] Hacker
题目描述
Byteasar the hacker has qualified for this year’s IHO, the International Hacking Olympiad. One of the tasks in the Olympiad involves competing against a system operator. There are computers numbered from to ,connected in a ring topology, i.e. computers and are connected , and also computers and are connected. The competition is performed as a game between the hacker and the system operator:
- Byteasar moves first. Afterwards, the operator and Byteasar move alternately.
- In his first move, Byteasar chooses any computer and hacks it (for instance,by exploiting some operating system vulnerabilities).
- In his first move, the operator chooses any non-hacked computer and protects it (for instance, by installing latest security upgrades).
- In all his following moves, Byteasar either (a) does nothing or (b) chooses any computer that is neither hacked nor protected and is directly linked to any hacked computer, and hacks it.
- In all his following moves, the operator either (a) does nothing or (b) chooses any computer that is neither hacked nor protected and is directly linked to any protected computer, and protects it.
- The game ends as soon as both have done nothing in two subsequent moves.
At the beginning of the game none of the computers are hacked or protected. Every computer has a certain value viwhich specifies the value of the data which is stored on it. For each hacked computer , Byteasar scores its value . Byteasar is quite a good hacker, but has no idea of algorithms. That is why he asks you to write a program that computes his maximum possible score, assuming that the operator plays optimally.
输入格式
The first line of input contains a positive integer , specifying the number of computers. The second line contains a sequence of integers ; number vispecifies the value of the data stored on computer .
输出格式
In the first and only line of output your program should write one integer: Byteasar’s maximum possible score against an optimally playing operator.
4
7 6 8 4
13
5
1 1 1 1 1
3
提示
Explanation to the examples: In the first example, Byteasar in his first move should hack computer (scoring ). The operator’s response will be protecting computer . In the next move Byteasar can hack computer (scoring ). Finally, the operator will protect computer .
以下子任务与评测无关,仅供参考。