P26695 [AtCoder] JOI 2006 Preliminary Problem 1
普及
题目描述

Problem Description

Two players, A and B, play a game using cards numbered from 0 to 9. Initially, each player is given $n$ cards, which are placed face-down in a row. Then, they sequentially flip one card from the left of their row, and the player with the higher number on the card takes both cards. The sum of the numbers on these two cards is the score for the player who took them. If the two cards have the same number, it is a draw, and each player takes their own card.

For example, consider the following cases from sample input 1 to 3. The input consists of $n + 1$ lines, where the first line contains the number of cards $n$ for each player, and the $i + 1$th line (for $i = 1, 2, \ldots, n$) contains the number on the $i$th card from the left for A and B, separated by a space. That is, the second line onwards represents the sequence of A's cards on the left and B's cards on the right. After the game ends, the scores of A and B will be as shown in the corresponding sample output.

Write a program that outputs the final scores of A and B, in this order, separated by a space, after the game corresponding to the input ends. Here, $n \leq 10,000$.

In the output, include a newline after B's score.


Input Format

None

Output Format

None

Sample Input and Output

Sample Input #1

3
9 1
5 4
0 8

Sample Output #1

19 8

Sample Input #2

3
9 1
5 4
1 0

Sample Output #2

20 0

Sample Input #3

3
9 1
5 5
1 8

Sample Output #3

15 14

Notes/Hints

Sample Explanation 1

- - - - - -

Sample Explanation 2

- - - - - -

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 9 1 5 4 0 8
样例输出
19 8