hdu 4939 Stupid Tower Defense dp
来源:互联网 发布:阿里云大学在哪里 编辑:程序博客网 时间:2024/05/16 18:42
Stupid Tower Defense
Time Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1986 Accepted Submission(s): 545
Problem Description
FSF is addicted to a stupid tower defense game. The goal of tower defense games is to try to stop enemies from crossing a map by building traps to slow them down and towers which shoot at them as they pass.
The map is a line, which has n unit length. We can build only one tower on each unit length. The enemy takes t seconds on each unit length. And there are 3 kinds of tower in this game: The red tower, the green tower and the blue tower.
The red tower damage on the enemy x points per second when he passes through the tower.
The green tower damage on the enemy y points per second after he passes through the tower.
The blue tower let the enemy go slower than before (that is, the enemy takes more z second to pass an unit length, also, after he passes through the tower.)
Of course, if you are already pass through m green towers, you should have got m*y damage per second. The same, if you are already pass through k blue towers, the enemy should have took t + k*z seconds every unit length.
FSF now wants to know the maximum damage the enemy can get.
The map is a line, which has n unit length. We can build only one tower on each unit length. The enemy takes t seconds on each unit length. And there are 3 kinds of tower in this game: The red tower, the green tower and the blue tower.
The red tower damage on the enemy x points per second when he passes through the tower.
The green tower damage on the enemy y points per second after he passes through the tower.
The blue tower let the enemy go slower than before (that is, the enemy takes more z second to pass an unit length, also, after he passes through the tower.)
Of course, if you are already pass through m green towers, you should have got m*y damage per second. The same, if you are already pass through k blue towers, the enemy should have took t + k*z seconds every unit length.
FSF now wants to know the maximum damage the enemy can get.
Input
There are multiply test cases.
The first line contains an integer T (T<=100), indicates the number of cases.
Each test only contain 5 integers n, x, y, z, t (2<=n<=1500,0<=x, y, z<=60000,1<=t<=3)
The first line contains an integer T (T<=100), indicates the number of cases.
Each test only contain 5 integers n, x, y, z, t (2<=n<=1500,0<=x, y, z<=60000,1<=t<=3)
Output
For each case, you should output "Case #C: " first, where C indicates the case number and counts from 1. Then output the answer. For each test only one line which have one integer, the answer to this question.
Sample Input
12 4 3 2 1
Sample Output
Case #1: 12HintFor the first sample, the first tower is blue tower, and the second is red tower. So, the total damage is 4*(1+2)=12 damage points.
Author
UESTC
Source
2014 Multi-University Training Contest 7
Recommend
We have carefully selected several similar problems for you: 5566 5565 5564 5563 5562
#include<cstdio>#include<string>#include<cstring>#include<iostream>#include<cmath>#include<algorithm>#include<climits>#include<queue>#include<vector>#include<map>#include<sstream>#include<set>#include<stack>#include<cctype>#include<utility>#pragma comment(linker, "/STACK:102400000,102400000")#define PI (4.0*atan(1.0))#define eps 1e-10#define sqr(x) ((x)*(x))#define FOR0(i,n) for(int i=0 ;i<(n) ;i++)#define FOR1(i,n) for(int i=1 ;i<=(n) ;i++)#define FORD(i,n) for(int i=(n) ;i>=0 ;i--)#define lson ind<<1,le,mid#define rson ind<<1|1,mid+1,ri#define MID int mid=(le+ri)>>1#define zero(x)((x>0? x:-x)<1e-15)#define mk make_pair#define _f first#define _s secondusing namespace std;//const int INF= ;typedef long long ll;//const ll inf =1000000000000000;//1e15;//ifstream fin("input.txt");//ofstream fout("output.txt");//fin.close();//fout.close();//freopen("a.in","r",stdin);//freopen("a.out","w",stdout);const int INF =0x3f3f3f3f;const int maxn= 1500+20 ;//const int maxm= ;ll n,x,y,z,t;ll maxi,dp[maxn][maxn];//dp[i][j]表示前面放了i个塔,其中有j个蓝塔。int main(){ int T,kase=0;scanf("%d",&T); while(T--) { scanf("%lld%lld%lld%lld%lld",&n,&x,&y,&z,&t); maxi=t*n*x; //注意状态的表示,以及对于任意一种方法 红塔应该放在最后。 //但没想到红塔的伤害可以在O(1)时间内算出。 //就是枚举i和j然后可以求出红塔的伤害。这里用了“红塔应该放在最后”; for(int i=1;i<=n;i++) { for(int j=0;j<=i;j++) { if(!j) dp[i][j]=dp[i-1][j]+ t*(i-1)*y ; //此步放绿塔 else dp[i][j]=max(dp[i-1][j] + (t+ j*z) *max(0,(i-j-1))*y,//绿 dp[i-1][j-1]+ (t+ max(0,j-1 )*z) *(i-j)*y );//蓝 maxi=max(maxi, dp[i][j]+(t+j*z)* (n-i)*(x+ (i-j)*y ) );//之后放红塔 } } printf("Case #%d: %lld\n",++kase,maxi); } return 0;}
0 0
- HDU 4939 Stupid Tower Defense dp
- hdu 4939 Stupid Tower Defense(dp)
- HDU 4939 Stupid Tower Defense dp
- hdu 4939 Stupid Tower Defense dp
- HDU 4939 - Stupid Tower Defense (DP)
- HDU 4939 Stupid Tower Defense(DP)
- HDU 4939 Stupid Tower Defense(贪心+dp)
- HDU 4939 Stupid Tower Defense (DP)
- hdu 4939 Stupid Tower Defense (dp)
- hdu Stupid Tower Defense 4939 dp
- HDU 4939 Stupid Tower Defense 简单DP
- hdu 4939 Stupid Tower Defense DP
- HDU 4939 Stupid Tower Defense(dp+贪心)
- 【HDU】4939 Stupid Tower Defense 【dp】
- hdu 4939 Stupid Tower Defense() dp
- HDU 4939 Stupid Tower Defense (DP)
- hdu 4939 Stupid Tower Defense dp
- HDU 4939-E - Stupid Tower Defense-DP
- 指针作为函数参数传递
- Extjs5 Gridpanel
- 超简单拼图实现
- python之字符串格式化(format)
- 一位开发者的 Linux 容器之旅
- hdu 4939 Stupid Tower Defense dp
- Extjs xtypes 常见示例
- 百度校招小结:我做技术面试官的一些思考
- 第11条:谨慎地覆盖clone
- Android之Paint属性介绍
- Android的核心包括几部分
- 排序算法
- 【笨木头Unity】入门之旅010(完结):Demo之四处找死(五)_UI
- Android Studio混淆打包配置