sicily 1134

来源:互联网 发布:windows截图保存在哪 编辑:程序博客网 时间:2024/06/06 02:15
#include <cstdio>#include <iostream>#include <algorithm>using namespace std;struct Info{int a;int b;};bool comp (const Info &temp1, const Info &temp2){return temp1.b < temp2.b;}int main(){int n, s;while (cin >> n >> s && n != 0){Info *a = new Info[n];for (int i = 0; i < n; i++)cin >> a[i].a >> a[i].b;sort(a, a + n, comp);int sum = s, i;bool flag = true;for (i = 0; i < n; i++){if (sum < a[i].b){flag = false;break;}sum += a[i].a;}if (flag)cout << "YES" << endl;elsecout << "NO" << endl;}}

 
原创粉丝点击