Saleh127

codechef july cardgame

Jul 3rd, 2020 (edited)
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9.  
  10. test
  11. {
  12.  
  13. ll n,a,c,d,e,f,i,j,k,l,ch=0,mr=0;
  14. cin>>n;
  15. while(n--)
  16. {
  17. cin>>a>>c;
  18. e=0;
  19. d=0;
  20. while(a)
  21. {
  22. d+=a%10;
  23. a/=10;
  24. }
  25. while(c)
  26. {
  27. e+=c%10;
  28. c/=10;
  29. }
  30. if(d>e) ch++;
  31. else if(e>d) mr++;
  32. else
  33. {
  34. ch++;
  35. mr++;
  36. }
  37. }
  38. if(ch>mr) cout<<0<<" "<<ch<<endl;
  39. else if(ch<mr) cout<<1<<" "<<mr<<endl;
  40. else cout<<2<<" "<<ch<<endl;
  41. }
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment