Warcraft III Time Limit: 10000 MS Description dccmx likes playing Warcraft III. Now, he is teaching his girlfriend to play it. In Warcraft III, there
2012-09-15 21:48
471 查看
#include<stdio.h>//动态规划,基本的背包类型。
#include<string.h>
#define MAX 100000
int tot[MAX],attack[MAX],cost[MAX];
int main()
{
int g,u,i,j;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&g,&u);
memset(tot,0,sizeof(tot));
for(i=0;i<u;i++)
{
scanf("%d",&attack[i]);
scanf("%d",&cost[i]);
}
for(i=0;i<u;i++)
for(j=cost[i];j<=g;j++)
{
if(tot[j]<tot[j-cost[i]]+attack[i])
tot[j]=tot[j-cost[i]]+attack[i];
}
printf("%d\n",tot[g]);
}
return 0;
}
#include<string.h>
#define MAX 100000
int tot[MAX],attack[MAX],cost[MAX];
int main()
{
int g,u,i,j;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&g,&u);
memset(tot,0,sizeof(tot));
for(i=0;i<u;i++)
{
scanf("%d",&attack[i]);
scanf("%d",&cost[i]);
}
for(i=0;i<u;i++)
for(j=cost[i];j<=g;j++)
{
if(tot[j]<tot[j-cost[i]]+attack[i])
tot[j]=tot[j-cost[i]]+attack[i];
}
printf("%d\n",tot[g]);
}
return 0;
}
相关文章推荐
- He had an operation in his knee.but now he is feeling like a million dollar,apparently the pain in his knee is all gone
- It is time now to proceed to the last part of the speculation
- date(): It is not safe to rely on the system's timezone settings in CodeIgniter
- 323. Nothing in the world is difficult for one who sets his mind to it. 世上无难事,只怕有心人
- HDU 4627 There are many unsolvable problem in the world.It could be about one or about zero.But this time it is about bigger number.
- this path is in ef to find it,if i have enough time i will to visite this website again
- Is there a limit to the number of columns in an HBase row?
- It is said that wars in the 21st century will be fought over water. Do you agree? What do you think can be done now to alleviate
- warning: strtotime(): It is not safe to rely on the system's timezone settings
- 关于linux内核 linux-2.6.34 编译报 unable to find suitable fs in /proc/mount,is it mounted? 问题说明
- The project could not be compiled. Would you like to open it in Xcode?
- 【Phpadmin】解决phpadmin的“It is not safe to rely on the system’s timezone settings”问题
- [ERROR] The goal you specified requires a project to execute but there is no POM in this directory
- Is it possible to implement IPv6 on a virtual interface (eth0:1 interface) in Linux?
- Popular now play is to look at the animals
- This function has none of Deterministic,no sql,or reads sql data in its declaration and binary logging is enabled(you *might* want to use the less safe log_bin_trust_function_creators variable
- date(): It is not safe to rely on the system’s timezone settings.
- PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings
- solr或lucene中出现there are more terms than documents in field "name", but it's impossible to sort on tokenized fields异常
- Why did Jimmy Wales invest in Quora? Is he afraid that it will take over Wikipedia?