hdu2831 2010.3.6

hdu2831 2010.3.6

植物大战僵尸  贪心  

#include <stdio.h>
#include <string.h>

#define MAXN 100+10

int a[MAXN],b[MAXN],c[MAXN];
int n,t;
int flag;

void qsort(int l,int r)
{
int i,j,x,y;
i=l;
j=r;
x=a[(l+r)/2];
do
{
while (a[i]<x) i++;
while (x<a[j]) j--;
if (i<=j)
{
y=a[i];
a[i]=a[j];
a[j]=y;
y=b[i];
b[i]=b[j];
b[j]=y;
i++;
j--;
};
}
while (i<=j);
if (l<j) qsort(l,j);
if (i<r) qsort(i,r);
}
void main()
{
	while (scanf("%d %d",&n,&t)!=EOF)
	{
		int i,x,y;
		flag=1;
		for(i=1;i<=n;i++)
		{
			scanf("%d %d",&x,&y);
			a[i]=x-y;
			b[i]=i;
			if (a[i]<0) flag=0;
		}
		if (flag)
		{
			qsort(1,n);
			for(i=1;i<=n;i++)
				if (a[i]<t*i)
				{
					flag=0;
					break;
				}
				else
					c[i]=b[i];
		}
		if (flag)
		{
			for(i=1;i<n;i++)
				printf("%d ",c[i]);
			printf("%d\n",c[n]);
		}
		else
			printf("The zombies eat your brains!\n");
	}
}

Plants VS Zombies

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 226    Accepted Submission(s): 70

Special Judge

 

Problem Description

Plants VS Zombies is a popular game in theTJU ACM Team now. However, RoBa is not very good at this game, so he wants youto write a program to help him.

 

We take a simplified version of this game.There are N rows in your backyard, and there are N zombies want to walk throughyour yard to eat your brain, and exactly one zombie in each row. The onlymethod to defense the zombies is to plant “peashooter” on the other side of theyard. However, you need T seconds to plant one peashooter. Once the peashooteris planted, it will begin to shoot at the zombies in its row. The zombies havedifferent speed Vi and defense Di, which means that, the zombie in the i-th rowneed Vi second the walk though the yard, and the i-th zombie will be killedafter Di second of shooting. Please note you can only plant one peashooter ineach row.

 

 

 

Unfortunately, in some cases, for thezombies are too fast and/or too strong and/or your planting is too slow, youcannot kill all the zombies in time, so the zombies will eat your brains.

 

 

 

Input

There are several test cases in the input.The first line of each test case contains two integers N (1 <= N <= 100)and T, indicating the number of rows and the time for planting one peashooter.Then N lines follow, each of which contains two integers Vi and Di.

 

 

Output

Output one line for each test case. If youcan kill all the zombies, output N numbers separated by a space, that is, apermutation of 1,2,…N, indicating the order of your planting. If you cannotdefend your yard, output “The zombies eat your brains!” in one line.

 

 

Sample Input

3 10

20 10

40 10

30 10

3 10

20 10

40 11

30 10

 

 

Sample Output

1 3 2

The zombies eat your brains!

Hint

Hint: For the first case, you should planta peashooter in the first row, then plant in the third row, then the secondrow.

Then all the zombies are killed just intime. For the second case, however, the zombie in second row is a littlestronger, so you cannot kill all of them.

 

 

 

Source

2009 Multi-University Training Contest 2 -Host by TJU

 

 

Recommend

gaojie

 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值