fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define ms(s,n) memset(s,n,sizeof(s))
  5. #define all(a) a.begin(),a.end()
  6. #define present(t, x) (t.find(x) != t.end())
  7. #define sz(a) int((a).size())
  8. #define FOR(i, a, b) for (int i = (a); i < (b); ++i)
  9. #define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)
  10. #define pb push_back
  11. #define pf push_front
  12. #define fi first
  13. #define se second
  14. #define mp make_pair
  15.  
  16. typedef long long ll;
  17. typedef unsigned long long ull;
  18. typedef long double ld;
  19. typedef pair<int,int> pi;
  20. typedef vector<int> vi;
  21. typedef vector<pi> vii;
  22.  
  23. const int MOD = (int) 1e9+7;
  24. const int INF = (int) 1e9+1;
  25. inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
  26. inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
  27.  
  28.  
  29.  
  30. int main(){
  31. #ifndef ONLINE_JUDGE
  32. freopen("input.txt", "r", stdin);
  33. freopen("output.txt", "w", stdout);
  34. #endif
  35. int n; scanf("%d", &n);
  36. pair<int,int> a[n];
  37. for(int i = 0; i < n; i++){
  38. cin >> a[i].first >> a[i].second;
  39. }
  40. //sap xep theo thoi gian den
  41. sort(a, a + n);
  42. int end_time = - 1;
  43. for(int i = 0; i < n; i++){
  44. //neu thoi gian den lam thu tuc cua nguoi hien tai
  45. //lon hon thoi gian ket thuc check in cua nguoi lam truoc do
  46. //thi nguoi hien tai se doi toi dung thoi gian bat dau lam thu tuc cua minh
  47. //nguoc lai thi nguoi nay se bat dau check in tu
  48. //thoi gian ket thuc cua nguoi truoc
  49. end_time = max(end_time, a[i].first);
  50. end_time += a[i].second;
  51. }
  52. cout << end_time << endl;
  53. return 0;
  54. }
  55.  
Success #stdin #stdout 0s 5680KB
stdin
Standard input is empty
stdout
0