-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy path230A. Dragons.cpp
41 lines (36 loc) · 848 Bytes
/
230A. Dragons.cpp
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
//============================================================================
//problem link:http://codeforces.com/contest/230/problem/A
// Name : .cpp
// Author : mohand sakr
// Version :
// Copyright : use it under your responsibility
// Description : Hello World in C++, Ansi-style
//status:Accepted
//============================================================================
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
vector<pair<int ,int> > pa;
int s,n;
cin>>s>>n;
bool can=true;
for(int i=0;i<n;i++){
int x,y;
cin>>x>>y;
pa.push_back(make_pair(x,y));
}
sort(pa.begin(),pa.end());
for(int i=0;i<n;i++){
if(s>pa[i].first){
s+=pa[i].second;
}
else{
can=0;
break;
}
}
if(can)cout<<"YES";else cout<<"NO";
return 0;
}