Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b75c01c

Browse files
authored
July Challenge 2020 Division 2
1 parent e6a7eba commit b75c01c

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

‎CRDGAME.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Problem link - https://www.codechef.com/JULY20B/problems/CRDGAME
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
#define f(i,a,b) for(i=a;i<b;i++)
7+
#define rep(i,n) f(i,0,n)
8+
#define fd(i,a,b) for(i=a;i>=b;i--)
9+
#define lli long long int
10+
#define vi vector<int>
11+
#define vll vector<lli>
12+
#define pb push_back
13+
#define all(v) v.begin(),v.end()
14+
15+
lli sumdigits(lli n){
16+
lli sum = 0;
17+
while(n){
18+
sum+=n%10;
19+
n/=10;
20+
}
21+
return sum;
22+
}
23+
24+
void solve(){
25+
lli n,i,chef_rounds=0,morty_rounds=0;
26+
cin >> n;
27+
rep(i,n){
28+
lli t1, t2;
29+
cin >> t1 >> t2;
30+
if(sumdigits(t1) < sumdigits(t2)){
31+
morty_rounds++;
32+
}else if(sumdigits(t2) < sumdigits(t1)){
33+
chef_rounds++;
34+
}else{
35+
morty_rounds++;
36+
chef_rounds++;
37+
}
38+
}
39+
if(morty_rounds < chef_rounds){
40+
cout << 0 << " " << chef_rounds << endl;
41+
}else if(chef_rounds < morty_rounds){
42+
cout << 1 << " " << morty_rounds << endl;
43+
}else{
44+
cout << 2 << " " << chef_rounds << endl;
45+
}
46+
}
47+
48+
int main(){
49+
ios::sync_with_stdio(0);
50+
cin.tie(0);
51+
cout.tie(0);
52+
53+
int test_cases;
54+
//test_cases = 1;
55+
cin >> test_cases;
56+
while(test_cases--){
57+
solve();
58+
}
59+
return 0;
60+
}

0 commit comments

Comments
(0)

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