-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path230A - Dragons.cpp
More file actions
47 lines (45 loc) · 838 Bytes
/
230A - Dragons.cpp
File metadata and controls
47 lines (45 loc) · 838 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
36
37
38
39
40
41
42
43
44
45
46
47
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
using namespace std;
bool sortbysec( pair<int,int> &a, pair<int,int> &b)
{
return (a.second < b.second);
}
int main(){
std::ios_base::sync_with_stdio(false);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt","w",stdout);
#endif
int s,n;
cin>>s>>n;
pair <int ,int > p;
vector< pair<int ,int > > v;
bool yes=true;
for(int i=0;i<n;i++){
int x,y;
cin>>x>>y;
p = make_pair(x,y);
v.pb(p);
}
sort(v.begin(),v.end());
int c=0;
for(int i=0;i<n;i++){
// cout<<v[i].first<<" "<<v[i].second<<endl;
if(v[i].first>=s){
yes=false;
break;
}
s+=v[i].second;
}
// cout<<c;
if(yes){
cout<<"YES\n";
}
else{
cout<<"NO\n";
}
return 0;
}