Potato
InterviewTime limit1sMemory limit1024 MB
Park and Sungwoo take turns grabbing whole plates of fries, Park first, and the task is to find each player's total under optimal play.
Problem
Park, who loves french fries, is unlike Sungwoo, who does not like them that much. One day Park and Sungwoo receive a large pile of french fries and decide to split them.
There are plates on the desk. The -th plate has fries. Park and Sungwoo take turns doing the following.
- Choose one plate that remains on the desk, and take the plate together with all the fries on it.
Repeat this until no plates remain on the desk. Park takes the first plate.
Park wants to maximize the number of fries he takes, and Sungwoo wants to minimize the number of fries he takes. Assuming both always play optimally, find the total number of fries that Sungwoo and Park each take in the end.
Input
The first line contains the number of plates .
The second line contains the number of fries on each plate, , separated by spaces.
Output
On the first line, print the number of fries that Sungwoo takes and the number of fries that Park takes, separated by a space.
Hint
Park is Sungwoo's rival.