Skip to content

Instantly share code, notes, and snippets.

@fullmated
Created May 1, 2011 07:52
Show Gist options
  • Save fullmated/950333 to your computer and use it in GitHub Desktop.
Save fullmated/950333 to your computer and use it in GitHub Desktop.
Aizu Online Judge No.0500 "Card Game"
#include <cstdio>
#include <cstdlib>
// input values
int n = 1;
int *a_card, *b_card;
int main(){
// This loop is one mass.
while(1){
int a_score = 0, b_score = 0;
scanf("%d", &n);
if(!n) break;
a_card = (int *)calloc(n, sizeof(int));
b_card = (int *)calloc(n, sizeof(int));
for(int i = 0; i < n; i++){
scanf("%d %d",a_card + i, b_card + i);
}
// big or small judge
for(int i = 0; i < n; i++){
if(a_card[i] == b_card[i]){
a_score += a_card[i];
b_score += b_card[i];
}
else if(a_card[i] > b_card[i]){
a_score += a_card[i] + b_card[i];
}else{
b_score += a_card[i] + b_card[i];
}
}
printf("%d %d\n", a_score, b_score);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment