fork(2) download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. long long n,x;cin>>n;
  9. long long score[n+1];
  10. long long player[n];
  11. score[0]=0;
  12. for(int i=1;i<=n;i++){
  13. int a,b;cin>>a>>b;
  14. if(a>b){score[i]=score[i-1]-(a-b);
  15. if(score[i]<0){score[i]=score[i]*(-1);}
  16. player[i-1]=1;
  17. }
  18. else{score[i]=score[i-1]-(b-a);
  19. if(score[i]<0){score[i]=score[i]*(-1);}
  20. player[i-1]=2;
  21. }
  22. } long long max = score[0];
  23. for (int i = 1; i <= n; i++) {
  24. if (score[i] > max){
  25. max = score[i];
  26. }}
  27. for(int i=0;i<=n;i++){
  28. if(max==score[i]){x=player[i-1];}
  29. }
  30. cout<< x<<" "<< max<<endl;
  31.  
  32. return 0;
  33. }
  34.  
Runtime error #stdin #stdout 0s 4472KB
stdin
Standard input is empty
stdout
Standard output is empty