MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / main

Function main

CodeChef_problems/CHEF AND CARD GAME/SOLUTION.cpp:8–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6 return sum;
7}
8int main() {
9 // your code goes here
10 int t;
11 cin>>t;
12 while(t--){
13//i hve taken a function to perform the sum as it was said in question
14 long long int a,b,n,s1=0,s2=0,count1=0,count2=0,i;
15 cin>>n;
16 for(i=0;i<n;i++)
17 {
18 cin>>a>>b;
19 s1=summ(a);
20 s2=summ(b);
21//then i stored those sum in seperate variable s1 and s2 for a and b resp.
22//f the sum of a is greater then b count 1 will increment which is for a
23 if(s1>s2){
24 count1++;
25
26 }
27//else count 2 will increment for b
28 else if(s2>s1){
29 count2++;
30 }
31//if they are equal both will increment
32 else{
33 count1++;
34 count2++;
35 }
36
37 }
38//comparing the counts
39//0 for a
40//1 for b
41//and if equal print 2 along with any count one will do
42 if(count1>count2){
43 cout<<0<<" "<<count1<<endl;
44 }
45 else if(count2>count1){
46 cout<<1<<" "<<count2<<endl;
47 }
48 else{
49 cout<<2<<" "<<count2<<endl;
50 }
51 }
52 return 0;
53}

Callers

nothing calls this directly

Calls 1

summFunction · 0.85

Tested by

no test coverage detected