Problem B
Bazaar
In an epic but tiny pirate game, several players compete for resources in order to gain a large enough booty to bury at deserted islands. After pillaging resources from peaceful settlements, players need to visit the bazaar in order to exchange their goods for pieces o’ eight to add to their booty.
There are
Two players are in the endgame phase of a match, and are now
rapidly trying to sell off all their pillaged goods. At the
moment, each player is in possession of exactly
Input
The first line contains the even integer
The next line contains
Output
Output a single integer: the number of pieces o’ eight the first player receives minus the number of pieces o’ eight the second player receives, if playing optimally as described in the statement.
Scoring
Your solution will be tested on a set of test groups, each worth a number of points. To get the points for a test group you need to solve all test cases in the test group.
Group |
Points |
Constraints |
|
|
|
|
|
|
|
|
No additional constraints. |
Explanation of sample 3
At the start of the game, the goods of the first player are
priced
The first player receives a total of
Sample Input 1 | Sample Output 1 |
---|---|
2 1 2 |
-1 |
Sample Input 2 | Sample Output 2 |
---|---|
2 2 1 |
0 |
Sample Input 3 | Sample Output 3 |
---|---|
4 1 2 3 4 |
-3 |