Advertisement
Pearlfromsu

fdafa https://codeforces.com/problemset/problem/230/A fda

Feb 5th, 2024
941
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.92 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <numeric>
  5. #include <math.h>
  6. #include <cmath>
  7. #include <vector>
  8. #include <string>
  9. #include <set>
  10. #include <stack>
  11. #include <queue>
  12. #include <map>
  13. #include <unordered_map>
  14. #include <iomanip>
  15. #define pdd pair<double, double>
  16. using namespace std;
  17.  
  18. int gcd(int a, int b) {
  19.     if (a < b)
  20.         swap(a, b);
  21.     if (b == 0)
  22.         return a;
  23.     return gcd(b, a % b);
  24. }
  25. int main() {
  26.     int s, n;
  27.     cin >> s >> n;
  28.     vector<pair<int, int>> vc(n);
  29.     for (int i = 0; i < n; i++) {
  30.         cin >> vc[i].first >> vc[i].second;
  31.     }
  32.     sort(vc.begin(), vc.end());
  33.     int cur = s;
  34.     for (int i = 0; i < vc.size(); i++) {
  35.         if (cur > vc[i].first) {
  36.             cur += vc[i].second;
  37.         }
  38.         else {
  39.             cout << "NO";
  40.             return 0;
  41.         }
  42.     }
  43.     cout << "YES";
  44.    
  45.  
  46.     return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement