简单的贪心算法。。。
按Dragon的strength排序。。。
#include <algorithm>
#include <iostream>
using namespace std;
struct cmp {
int x, y;
}array[1005];
bool tmp ( cmp a, cmp b ) {
return a.x < b.x;
}
int main ( ) {
int s, n, x, y, ans;
ans = 0;
cin >> s >> n;
for ( int i = 0; i < n; ++i )
cin >> array[i].x >> array[i].y;
sort ( array, array + n, tmp );
for ( int i = 0; i < n; ++i ) {
if ( s > array[i].x ) {
s += array[i].y;
ans++;
}
}
if ( ans == n ) cout << "YES" << endl;
else cout << "NO" << endl;
}