fork download
  1. /*Rabbi Zidni Eilmaa*/
  2.  
  3. // We are open. We are looking for SHOTRUJ...
  4.  
  5. #include <bits/stdc++.h>
  6. using namespace std;
  7.  
  8. typedef long long int ll;
  9. typedef long double ld;
  10. typedef string str;
  11. typedef vector<ll> vll;
  12. typedef vector<pair<ll, ll>> vpl;
  13. typedef set<ll> sll;
  14. typedef map<ll, ll> mll;
  15. typedef pair<int, int> pint;
  16. typedef pair<ll, ll> pll;
  17. double pi = acos(-1.0);
  18. #define debug(x) cout << #x << " " << x << endl;
  19. #define loop for (int i = 1; i <= n; i++)
  20. #define all(a) (a).begin(), (a).end()
  21. #define min3(a, b, c) min(a, min(b, c))
  22. #define max3(a, b, c) max(a, max(b, c))
  23. #define min4(a, b, c, d) min(a, min(b, min(c, d)))
  24. #define max4(a, b, c, d) max(a, max(b, max(c, d)))
  25. #define forn(i, n) for (int i = 1; i <= (int)n; i++)
  26. #define ANS cout << ans << "\n"
  27. #define PY cout << "YES\n"
  28. #define PN cout << "NO\n"
  29.  
  30. int mod = 1e9 + 7;
  31.  
  32. void init()
  33. {
  34.  
  35. }
  36.  
  37. bool comp(pair<ll, ll> a, pair<ll, ll> b) {
  38. if(a.first == b.first) return a.second <= b.second;
  39. return a.first <= b.first;
  40. }
  41.  
  42. void solve()
  43. {
  44. int n;
  45. cin >> n;
  46. ll d, t;
  47. cin >> d >> t;
  48. vector<pair<ll, ll>> vc;
  49. while(n--) {
  50. ll x, h;
  51. cin >> x >> h;
  52. if(x < d) vc.push_back({x, h});
  53. }
  54.  
  55. sort(vc.begin(), vc.end(), comp);
  56. __int128_t time = 0;
  57. ll pos = 0;
  58. for(auto pr: vc) {
  59. ll x = pr.first;
  60. ll h = pr.second;
  61.  
  62. time += __int128_t(x - pos);
  63. pos = x - h;
  64. }
  65. time += (d - pos);
  66.  
  67. cout << ((time <= t)? "YES\n" : "NO\n");
  68.  
  69. return;
  70. }
  71.  
  72. int32_t main()
  73. {
  74. ios_base::sync_with_stdio(0);
  75. cin.tie(0);
  76. cout.tie(0);
  77.  
  78. init();
  79. int t = 1;
  80. // cin >> t;
  81. for (int i = 1; i <= t; i++)
  82. {
  83. // cout << "Case " << i << ": ";
  84. solve();
  85. }
  86.  
  87. return 0;
  88. }
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
YES