Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <algorithm>
- #include <numeric>
- #include <math.h>
- #include <cmath>
- #include <vector>
- #include <string>
- #include <set>
- #include <stack>
- #include <queue>
- #include <map>
- #include <unordered_map>
- #include <iomanip>
- #define pdd pair<double, double>
- using namespace std;
- int gcd(int a, int b) {
- if (a < b)
- swap(a, b);
- if (b == 0)
- return a;
- return gcd(b, a % b);
- }
- int main() {
- int s, n;
- cin >> s >> n;
- vector<pair<int, int>> vc(n);
- for (int i = 0; i < n; i++) {
- cin >> vc[i].first >> vc[i].second;
- }
- sort(vc.begin(), vc.end());
- int cur = s;
- for (int i = 0; i < vc.size(); i++) {
- if (cur > vc[i].first) {
- cur += vc[i].second;
- }
- else {
- cout << "NO";
- return 0;
- }
- }
- cout << "YES";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement