Created
October 10, 2012 10:05
-
-
Save brickgao/3864518 to your computer and use it in GitHub Desktop.
Codeforces Round 142 (Div. 2) A
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//By Brickgao | |
#include <iostream> | |
#include <cstdio> | |
#include <cstring> | |
#include <cmath> | |
#include <cstdlib> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
typedef struct record{ | |
__int64 x; | |
__int64 y; | |
} record; | |
record rec[1010]; | |
__int64 s, n; | |
bool cmp(record a, record b) | |
{ | |
return a.x < b.x; | |
} | |
int main() | |
{ | |
bool flag = true; | |
cin >> s >> n; | |
for(__int64 i = 0; i < n; i++) | |
cin >> rec[i].x >> rec[i].y; | |
sort(rec, rec + n, cmp); | |
for(__int64 i = 0; i < n; i++) | |
{ | |
if(rec[i].x < s) | |
s += rec[i].y; | |
else | |
{ | |
flag = false; | |
break; | |
} | |
} | |
if(flag) | |
cout << "YES" << endl; | |
else | |
cout << "NO" << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment