fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int MAXN = 110;
  5. int n, a[MAXN], b[MAXN];
  6. pair <int, int> c[MAXN];
  7.  
  8. int main(){
  9. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  10. freopen("text.inp", "r", stdin);
  11. freopen("text.out", "w", stdout);
  12.  
  13. cin >> n;
  14. for (int i = 1; i <= n; i++) {
  15. cin >> a[i] >> b[i];
  16. c[i] = {a[i], b[i]};
  17. }
  18.  
  19. sort(c + 1, c + 1 + n);
  20. int res = 0;
  21. for (int i = 1; i <= n; i++) {
  22. if (res < c[i].first) res = c[i].first + c[i].second;
  23. else res += c[i].second;
  24. }
  25.  
  26. cout << res;
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty