记录编号 |
36173 |
评测结果 |
AAAAA |
题目名称 |
积木分发 |
最终得分 |
100 |
用户昵称 |
Makazeu |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.220 s |
提交时间 |
2012-03-09 22:24:46 |
内存使用 |
0.34 MiB |
显示代码纯文本
#include <cstdio>
#include <cstdlib>
using namespace std;
const int MAXN=10011;
class Toybrick
{
public:
int now,left;
}Toy[MAXN];
int N,S;
int cmp(const void *a,const void *b)
{
class Toybrick *c=(class Toybrick *)a;
class Toybrick *d=(class Toybrick *)b;
if(c->left!=d->left)
return c->left-d->left;
return d->now-c->now;
}
void init()
{
scanf("%d %d\n",&N,&S);
while(N!=0 || S!=0)
{
for(int i=1;i<=N;i++)
scanf("%d %d\n",&Toy[i].now,&Toy[i].left);
qsort(Toy+1,N,sizeof(Toybrick),cmp);
bool flag=1;
for(int i=1;i<=N;i++)
{
if(S<Toy[i].left)
{
flag=0;
break;
}
S+=Toy[i].now;
}
if(flag) printf("YES\n");
else printf("NO\n");
scanf("%d %d\n",&N,&S);
}
}
int main()
{
freopen("toybrick.in","r",stdin);
freopen("toybrick.out","w",stdout);
init();
return 0;
}