hdu-3177

来源:互联网 发布:网络连不上说是防火墙 编辑:程序博客网 时间:2024/06/07 00:11

关键句子:More precisely Crixalis can not move equipment into the hole unless there are Bi units of space left. After it moved in, the volume of the hole will decrease by Ai

简单贪心

#include<cstdio>#include<algorithm>#include<cmath>#include<iostream>using namespace std;struct node{int x,y;}a[1005];bool cmp(node a,node b){return a.x+b.y<a.y+b.x;}int main(){//freopen("d:\\test.txt","r",stdin);int t,i;scanf("%d",&t);while(t--){int v,n;scanf("%d%d",&v,&n);for(i=0;i<n;++i)scanf("%d%d",&a[i].x,&a[i].y);sort(a,a+n,cmp);int flag=0;for(i=0;i<n;++i){if(a[i].y>v){printf("No\n");flag=1;break;}elsev-=a[i].x;}if(!flag)printf("Yes\n");}return 0;}

  

原创粉丝点击