Logo
(追記) (追記ここまで)

15008번 - Falling Apart 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB34725623875.796%

문제

After acquiring a new integer and showing it off to other couples at a cocktail party, Alice and Bob headed home for a good night of sleep. As their integer was quite large, they were forced to carry it together. Then, on the Boole Boulevard, right by the Bayes Bay, disaster struck. History does not tell us which of our two protagonists stumbled first, but stumble they did, and their integer shattered into n positive integral pieces on the pavement in front of them.

The couple’s marriage, already under financial stress due to the expensive integer acquisition, did not survive this event, and Bob and Alice resolved to separate. Thus the question was raised on how to split the remnants of their integer. Bob and Alice decided to play a game with the remaining n pieces: the two would repeatedly choose pieces in alternating turns until none were left.

Bob and Alice, both very materialistic, seek to acquire the largest possible sum of integers possible. Compute the value of the integers each of them ends up with. Assume both players play optimally. Since A comes before B in the alphabet, Alice moves first.

입력

The input consists of two lines.

  • A single integer 1 ≤ n ≤ 15, the number of pieces.
  • The values of the pieces a0, a1, . . . , an−1, space-separated. It is given that 1 ≤ ai ≤ 100.

출력

Output a single line containing two integers, the combined value of Alice’s pieces, and the combined value of Bob’s pieces.

제한

예제 입력 1

3
3 1 2

예제 출력 1

4 2

예제 입력 2

4
1 2 2 1

예제 출력 2

3 3

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2017 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /