fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int a, b, c, diff, max=0, winner, temp, sc_1=0, sc_2=0;
  7. cin>>a;
  8. while(a--) {
  9. cin>>b>>c;
  10. sc_1=sc_1+b;
  11. sc_2=sc_2+c;
  12. if(sc_1>sc_2) {
  13. diff=sc_1-sc_2; temp=1;
  14. }
  15. else {
  16. diff=sc_2-sc_1; temp=2;
  17. }
  18. if(diff>max) {
  19. max=diff; winner=temp;
  20. }
  21. }
  22. cout<<winner<<" "<<max;
  23. return 0;
  24. }
Success #stdin #stdout 0s 3300KB
stdin
5
140 82
89 134
90 110
112 106
88 90
stdout
1 58