#P13505. [OOI 2024] Big Persimmon
[OOI 2024] Big Persimmon
题目描述
Alice and Bob bought a big persimmon, cut it into pieces with sizes , and immediately started eating it. The kids will eat the pieces simultaneously, and for each of them, the eating process is as follows:
As soon as someone finishes eating their previous piece (and at the beginning of the meal), they choose the next piece and start eating it. If a piece of size is taken, it will take exactly seconds to eat it, and then it will be time to choose a new piece. If both finish eating their previous piece at the same time (or if the eating just started), Alice will choose the first piece, but they will start eating at the same time. Choosing a new piece does not take time.
Since both Alice and Bob are perfectionists, when they choose a piece, they will take either the smallest (with the smallest ) or the largest (with the largest ) from all the remaining pieces.
The eating process ends when the last person finishes eating and there are no more pieces left.
Both Alice and Bob are interested in eating as much as possible. Find the total size of the pieces that Alice will eat and the total size of the pieces that Bob will eat, if they both choose the pieces optimally.
输入格式
The first line contains a single integer --- the number of persimmon pieces.
The second line contains integers (, ) --- the sizes of the persimmon pieces.
Let denote the sum of the sizes of all the pieces. It is guaranteed that .
输出格式
In a single line, output two numbers --- the total size of the pieces that Alice will eat and the total size of the pieces that Bob will eat, if they both choose the pieces optimally.
5
1 1 3 4 6
8 7
4
1 1 2 2
3 3
4
1 7 7 9
10 14
提示
Note
In the first example, Alice should first take a piece of size . Immediately after that, Bob should also take a piece of size . After a second, Alice will take a piece of size , and then Bob will take a piece of size . seconds later, Alice will take a piece of size . seconds later, Bob will finish eating, and a second later the process will finish. At this point, Alice will eat pieces of sizes , and Bob: .
In the third example, Alice should take a piece of size , and Bob should take a piece of size . After a second, Alice will take a piece of size , and seconds later, Bob will take a piece of size .
Scoring
The tests for this problem consist of four groups. Points for each group are given only if all tests of the group and all tests of the required groups are passed.. Note that passing the example tests is not required for some groups. means that the results of testing your solution on this group will only be available after the competition.
Group | Points | Additional constraints | < | Required Groups | Comment |
---|---|---|---|---|---|
0 | -- | -- | -- | Examples. | |
1 | 10 | -- | |||
2 | 12 | -- | |||
3 | 19 | 0 | |||
4 | 15 | -- | for all | ||
5 | 13 | -- | 2, 4 | ||
6 | 31 | 0 -- 5 | Offline-evaluation. |