-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path230A.cpp
More file actions
43 lines (35 loc) · 748 Bytes
/
Copy path230A.cpp
File metadata and controls
43 lines (35 loc) · 748 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
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#define mp make_pair
#define pb push_back
using namespace std ;
int main(){
int s, n ;
cin >> s >> n ;
vector< pair<int, int > > v ;
int strength, bonus ;
for(int i = 0 ;i < n; i++){
cin >> strength >> bonus ;
// cout << "s : " << strength << " b : " << bonus << endl ;
v.pb(mp(strength, bonus));
}
sort(v.begin(), v.end());
vector<pair<int, int > >::iterator it = v.begin();
bool died = false ;
for( ; it != v.end() ; ++it){
// cout << it->first << " " << it->second << endl ;
if (it->first < s){
s += it->second ;
} else {
died = true ;
}
}
if (!died){
cout << "YES" << endl ;
} else {
cout << "NO" << endl ;
}
return 0;
}