hdu 2831 plants VS zombies
来源:互联网 发布:高性能服务器编程 pdf 编辑:程序博客网 时间:2024/06/05 23:59
#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>using namespace std;//这道题属于贪心,那么我们首先就是对数据进行排序,所以我们先要找到以什么为标准进行排序//我们可以由题意理解到,解决一个僵尸所需要的时间是T+Di,那么接下来就是判断T+Di<Vi是否成立,如果成立//则可以解决僵尸,否则不能解决僵尸 // 以上是一个僵尸的判断//接下来要在前一个的基础上进行判断,那么此时所花费的时候便是T,判断第二个的时候就是判断T+T+Di<Vi是否成立 struct node{int v,d;int index;}edge[11000];int cmp(node a,node b){return (a.v-a.d)<(b.v-b.d);}int main(){int i;int flag;int n,t;int temp;while(scanf("%d%d",&n,&t)!=EOF){flag=0;for(i=1;i<=n;i++){scanf("%d%d",&edge[i].v,&edge[i].d);edge[i].index=i;}int temp=t;sort(edge+1,edge+1+n,cmp);for(i=1;i<=n;i++){if(edge[i].v-edge[i].d<t){flag=1;break;}t+=temp;}if(flag){printf("The zombies eat your brains!\n");continue;}for(i=1;i<=n;i++){i==1?printf("%d",edge[i].index):printf(" %d",edge[i].index);}printf("\n");}return 0;}
0 0
- hdu 2831 plants VS zombies
- hdu(2831)Plants VS Zombies
- bnu_4060 Plants vs. Zombies
- BNU4060:Plants vs. Zombies
- toj4120.Zombies VS Plants
- TOJ 4120 Zombies VS Plants
- TOJ 3307.Plants VS Zombies
- 游戏推荐——Plants vs. Zombies
- UVA 12452 Plants vs. Zombies HD SP 树形dp(水
- Google Play 出现假的植物大战殭尸2( Plants vs. Zombies 2)
- hdu2831Plants VS Zombies (贪心)
- 关于Plants versus Zombies游戏中的Pogo stick玩具
- SOJ4264 garlic and zombies
- UVAlive3532 Nuclear Plants
- poj1205 Water Treatment Plants
- NOJ 1127 Kill the Zombies
- 什么是僵死进程(Zombies)
- Cat VS Dog HDU
- iOS软件开发 类目延展协议的使用
- linux C守护进程编写http://www.cnblogs.com/ringwang/p/3528093.html
- BNUOJ 弱校联萌十一大决战之强力热身B Carries(二分)
- ${pageContext.request.contextPath }
- 黑马程序员-----多线程
- hdu 2831 plants VS zombies
- 程序设计基石与实践系列之失落的C语言结构体封装艺术
- 关于如何高效的解决问题的探索
- single模式
- 后缀自动机题目小结
- 建设“顺序表”算法库
- W3school学习笔记之CSS3
- python 中的 filter, lambda, map, reduce 内置函数
- gcc __attribute__详解