fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. struct xh
  4. {
  5. long long s;
  6. long long e;
  7. };
  8. xh x[1000006];
  9. bool ss(xh u,xh v)
  10. {
  11. return u.s<v.s;
  12. }
  13. int n;
  14. int main()
  15. {
  16. cin>>n;
  17. for(int i=1;i<=n;i++) cin>>x[i].s>>x[i].e;
  18. sort(x+1,x+n+1,ss);
  19. long long kq=LLONG_MIN;
  20. for(int i=1;i<=n;i++)
  21. {
  22. kq=max(kq,x[i].s);
  23. kq=kq+x[i].e;
  24. }
  25. cout<<kq;
  26. }
  27.  
Success #stdin #stdout 0s 5380KB
stdin
Standard input is empty
stdout
-9223372036854775808