fork(1) download
  1. #include<stdio.h>
  2. int main(){
  3. long a,b,c,d,g=0,h=0;
  4. int e=0,f;
  5. scanf("%ld",&a);
  6. for(b=0;b<a;b++){
  7. scanf("%ld %ld",&c,&d);
  8. g=g+c;
  9. h=h+d;
  10. if(g<h&&e<(h-g)){
  11. e=h-g;
  12. f=2;
  13. }
  14. else if(h<g&&e<(g-h))
  15. {
  16. e=g-h;
  17. f=1;
  18. }
  19. }
  20. printf("%d %d",f,e);
  21. return 0;
  22. }
Success #stdin #stdout 0s 2900KB
stdin
5
3 3
1
1
1
5 11
1
2
4
8
16
5 23
1
2
4
8
16
5 13
1
5
5
10
10
20 132
17
6
4
998
254
137
259
153
154
3
28
19
123
542
857
23
687
35
99
999
stdout
1 6