fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int k,b,c,d=0,e=0,f=-1;
  6. cin>>k;
  7. for(int i=0;i<k;i++){
  8.  
  9. cin>>b>>c;
  10. if(c==-1)d++;
  11. if(c>f){
  12. f=c;
  13. e=b;
  14.  
  15. }
  16. }
  17. if(f-k-d*2<0){cout<<'0';}
  18. else{cout<<f-k-d*2;}
  19. cout<<' '<<e;
  20. }
Success #stdin #stdout 0.01s 5300KB
stdin
5
3 89
5 -1
10 90
15 0
20 90
stdout
83 10