-
Notifications
You must be signed in to change notification settings - Fork 55
/
codechef_CRDGAME.cpp
54 lines (46 loc) · 1023 Bytes
/
codechef_CRDGAME.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
using namespace std;
int sumA,sumB;
int main() {
int t;
cin>> t;
for(int i=0; i<t; i++)
{
int n;
int pA=0,pB=0;
cin>> n;
for(int j=0; j<n; j++){
int A,B;
sumA=0; sumB=0;
cin>>A>>B;
while(A>0){
sumA += (A%10);
A = A/10;
}
while(B>0){
sumB += (B%10);
B = B/10;
}
if(sumA>sumB){
pA += 1;
}
else if(sumB==sumA){
pA += 1;
pB += 1;
}
else{
pB +=1;
}
}
if(pB>pA){
cout<<1<<" "<<pB<<endl;
}
else if(pA>pB){
cout<<0<<" "<<pA<<endl;
}
else if(pB==pA){
cout<<2<<" "<<pB<<endl;
}
}
return 0;
}