fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int a,b;cin >> a >> b;
  6. int count = 0;
  7. pair<int,int> p[1000];
  8. for(int i = 0;i < b;++i)
  9. {
  10. cin >> p[i].first >> p[i].second;
  11. }
  12. sort(p,p + 1);
  13. for(int i = 0;i < b;i++)
  14. {
  15. if(a <= p[i].first)
  16. {
  17. count++;
  18. break;
  19. }
  20. else
  21. {
  22. a = a + p[i].second;
  23. }
  24. }
  25. if(count > 0)
  26. {
  27. cout << "NO";
  28. }
  29. else
  30. {
  31. cout << "YES";
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5504KB
stdin
10 1
100 100

stdout
NO