fork download
  1. #include <iostream>
  2. #include <cmath>
  3. #include<array>
  4. #include<string>
  5. #include<algorithm>
  6. #include<cstdlib>
  7. #include <string.h>
  8. #define ll long long
  9. #include <bits/stdc++.h>
  10. using namespace std;
  11.  
  12. struct rec {
  13. int x , y ;
  14. };
  15.  
  16. bool ca(rec a, rec b) {
  17. return a.x < b.x;
  18. }
  19.  
  20.  
  21. signed main() {
  22. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  23.  
  24. int s , n ;
  25. cin >> s >> n;
  26. //int ctrl = 0;
  27.  
  28. rec arr[n];
  29. for (int i = 0; i < n; i++) {
  30. cin >> arr[i].x >> arr[i].y;
  31. }
  32. sort(arr, arr + n , ca);
  33.  
  34. /*if (s > arr[0].x) {
  35.   ctrl++;
  36.   s = s + n ;
  37.   }*/
  38.  
  39. for (int i = 0; i < n; i++) {
  40. if (s > arr[i].x) {
  41. //ctrl++;
  42. s += arr[i].y ;
  43. }
  44. else {
  45. //ctrl = 0;
  46. cout << "No" << endl;
  47. return 0;
  48. }
  49. }
  50.  
  51.  
  52. cout << "Yes" << endl ;
  53.  
  54.  
  55. }
  56.  
  57.  
  58.  
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
No