-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path230A
More file actions
35 lines (34 loc) · 710 Bytes
/
Copy path230A
File metadata and controls
35 lines (34 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<bits/stdc++.h>
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int,int>
#define vpi vector<pii>
#define mp unordered_map<char,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ff first
#define ss second
#define MOD1 1000000007
#define MOD2 1000000009
using namespace std;
signed main(){
lli s,n,flag=0;
pii arr[1000];
while(cin>>s>>n){
for(int i=0; i<n;i++){
cin>>arr[i].first>>arr[i].second;
}
sort(arr,arr+n);
for(int i=0; i<n;i++){
if (s<=arr[i].first){
flag=1;
break;
}
else{
s+=arr[i].second;
}
}
if (flag==1) cout<<"NO\n";
else cout<<"YES\n";}
return 0;
}