Created
June 13, 2013 04:03
-
-
Save karszawa/5771163 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
AOJ 0500 'Card Game' | |
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0500 | |
*/ | |
import std.stdio; | |
import std.array; | |
import std.range; | |
import std.conv; | |
import std.string; | |
import std.algorithm; | |
void main() | |
{ | |
while(true) | |
{ | |
int N = readln().chomp().to!int(), A = 0, B = 0; | |
if(N == 0) break; | |
foreach(_; 0..N) | |
{ | |
auto line = readln().split.map!("a.to!int"); | |
int a = line[0], b = line[1]; | |
if(a > b) A += a + b; | |
if(a < b) B += a + b; | |
if(a == b) A += a, B += b; | |
} | |
writefln("%d %d", A, B); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment