Skip to content

Instantly share code, notes, and snippets.

@brickgao
Created October 10, 2012 10:05
Show Gist options
  • Save brickgao/3864518 to your computer and use it in GitHub Desktop.
Save brickgao/3864518 to your computer and use it in GitHub Desktop.
Codeforces Round 142 (Div. 2) A
//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