fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. #define mp make_pair
  4. #define f(i,n) for(int i=0;i<n;i++)
  5. #define F first
  6. #define S second
  7. #define pb push_back
  8.  
  9. using namespace std;
  10.  
  11. void test(){
  12. ll n,m,t;
  13. cin>>n>>m>>t;
  14. ll cap = n;
  15. bool flag = true;
  16. ll prev = 0;
  17. f(i,m){
  18. ll a,b;
  19. cin>>a>>b;
  20. n = n - (a-prev);
  21. if(n<=0)flag = false;
  22. n = min(cap,n + (b-a));
  23. prev = b;
  24. }
  25. n = n - (t-prev);
  26. if(n<=0)flag = false;
  27. if(flag)cout<<"Yes\n";
  28. else cout<<"No\n";
  29.  
  30. }
  31.  
  32. int main(){
  33. std::ios::sync_with_stdio(false);
  34. cin.tie(0);
  35. cout.tie(0);
  36. int tests=1;
  37. // cin>>tests;
  38. while(tests--){
  39. test();
  40. }
  41. }
  42.  
Success #stdin #stdout 0s 4968KB
stdin
10 2 20
9 11
13 17
stdout
Yes