hdu4939 Stupid Tower Defense (DP)
2014多校7 第二水的题
Stupid Tower DefenseTime Limit: 12000/6000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 366 Accepted Submission(s): 88 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. 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) 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
1
2 4 3 2 1 Sample Output
Case #1: 12
Hint
For 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
Recommend
|
题意:塔防,怪过每个块用的初始时间为t。每块可以建一个塔,有三种塔,一种是红塔,怪经过当前格子时每秒输出x;一种绿塔,怪过了当前格子后每秒被毒y血;一种是蓝塔,怪经过当前格子后经过每格的时间增加z秒。绿塔和蓝塔效果都可叠加,求最高输出。
题解:DP。
思考题面,可以想到红塔放最后是最优解,可以反证得:如果有个红塔后面有个不红的塔,交换它们肯定可以得更优解。
这样我们就枚举不红的塔的数量、绿塔的数量,f[i][j]表示有前面有i个不红的塔,其中绿塔有j个时,蓝绿塔在全路段的输出和。
因为已知i,j时,后面的红塔的输出也是固定的(只随着i,j变化,ij固定时红塔输出不变),所以我们dp求得各种ij的最大的f[i][j],ans每次更新。
由于数好像有点大,用超碉的会滚的队列比较爽。
//#pragma comment(linker, "/STACK:102400000,102400000")
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
#define ll long long
#define usll unsigned ll
#define mz(array) memset(array, 0, sizeof(array))
#define minf(array) memset(array, 0x3f, sizeof(array))
#define REP(i,n) for(i=0;i<(n);i++)
#define FOR(i,x,n) for(i=(x);i<=(n);i++)
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define RD3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define WN(x) prllf("%d\n",x);
#define RE freopen("D.in","r",stdin)
#define WE freopen("1biao.out","w",stdout)
ll max(ll x,ll y) {
return x>y?x:y;
}
ll f[][][];///green blue int main() {
ll T,cas=;
ll n,t;
ll x,y,z;
ll now,pre;
ll i,j,k;
scanf("%I64d",&T);
while(T--) {
scanf("%I64d%I64d%I64d%I64d%I64d",&n,&x,&y,&z,&t);
memset(f,,sizeof(f));
now=;
pre=;
ll ans=x*t*n;
for(i=; i<=n; i++) { ///第1到第i个不放红的
for(j=; j<=i; j++) { ///第1个到第i个有j个green
k=i-j;///第1个到第i个有k个blue
if(k>) {///第i个放蓝的
f[now][j][k]=f[pre][j][k-] + j*y*z*(n-i);///放这个蓝的接下来n-i格每格增加了z时间
}
if(j>) {///放绿的
f[now][j][k]=max(f[now][j][k],f[pre][j-][k] + y*(t+k*z)*(n-i) );///放这个绿的每秒增加y伤害
}
ans=max(ans,f[now][j][k] + x*(n-i)*(t+k*z));
}
pre=now;
now^=;
}
printf("Case #%I64d: %I64d\n",cas++,ans);
}
return ;
}
hdu4939 Stupid Tower Defense (DP)的更多相关文章
- 2014多校第七场1005 || HDU 4939 Stupid Tower Defense (DP)
题目链接 题意 :长度n单位,从头走到尾,经过每个单位长度需要花费t秒,有三种塔: 红塔 :经过该塔所在单位时,每秒会受到x点伤害. 绿塔 : 经过该塔所在单位之后的每个单位长度时每秒都会经受y点伤害 ...
- HDU 4939 Stupid Tower Defense(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4939 解题报告:一条长度为n的线路,路上的每个单元格可以部署三种塔来给走在这条路上的敌人造成伤害,第一 ...
- LightOJ 1033 Generating Palindromes(dp)
LightOJ 1033 Generating Palindromes(dp) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid= ...
- lightOJ 1047 Neighbor House (DP)
lightOJ 1047 Neighbor House (DP) 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730# ...
- UVA11125 - Arrange Some Marbles(dp)
UVA11125 - Arrange Some Marbles(dp) option=com_onlinejudge&Itemid=8&category=24&page=sho ...
- 【POJ 3071】 Football(DP)
[POJ 3071] Football(DP) Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4350 Accepted ...
- 初探动态规划(DP)
学习qzz的命名,来写一篇关于动态规划(dp)的入门博客. 动态规划应该算是一个入门oier的坑,动态规划的抽象即神奇之处,让很多萌新 萌比. 写这篇博客的目标,就是想要用一些容易理解的方式,讲解入门 ...
- Tour(dp)
Tour(dp) 给定平面上n(n<=1000)个点的坐标(按照x递增的顺序),各点x坐标不同,且均为正整数.请设计一条路线,从最左边的点出发,走到最右边的点后再返回,要求除了最左点和最右点之外 ...
- 2017百度之星资格赛 1003:度度熊与邪恶大魔王(DP)
.navbar-nav > li.active > a { background-image: none; background-color: #058; } .navbar-invers ...
随机推荐
- Ubuntu下matlab快捷键设置
ubuntu15.04, matlab2016a 默认按键ctrl+s无法保存,ctrl+z无法撤销.因为用的是emacs的快捷键.emacs的快捷键不熟悉会觉得很复杂,果断改为windows风格的: ...
- Linux文件系统介绍(转)
文章转自:http://www.iteye.com/topic/816268 文件系统是linux的一个十分基础的知识,同时也是学习linux的必备知识. 本文将站在一个较高的视图来了解linux的文 ...
- 小米手机(HM1SW)高通开发android程序全过程
小米手机(HM1SW)开发android程序全过程 修改历史: 2016年5月9日 -------- 整理文档 a.增加了手机基本信息. b.增加360手机助手连接说明 2016年2月26日 - ...
- lbs(查看附近的人),看看社交软件如何实现查看附近的人
最近在做一款移动端棋牌游戏,为了进一步提高用户体验.拉近玩家的距离,我们决定在游戏中加入好友功能,而对于体验好友功能的玩家来说,要是玩牌的时候可以看看附近都有谁在玩牌,跟他们交流交流玩牌心得什么的无疑 ...
- AngularJs ngIf、ngSwitch、ngHide/ngShow
在组合这些ng指令写到一篇文章里的时候,基本是有规则的,本兽会将功能相似相近的一类整合到一篇文章,方便理解和记忆. 这篇的三个指令也都是对DOM元素的操作,页面上显示/隐藏的判断,添加/移除的判断. ...
- 【Phylab2.0】Alpha版本测试报告
测试报告集 点击链接
- BZOJ1588[HNOI2002]营业额统计
传送门 平衡树常规题,给出两种实现算法 Treap版: //OJ 1610 //by Cydiater //2016.9.1 #include <iostream> #include &l ...
- 简单的angular表单验证指令
<html ng-app="myApp"> <head> <meta charset="UTF-8"> <title& ...
- WinForm------字段不能为空错误
错误信息: "System.Data.ConstraintException"类型的异常在 EntityFramework.dll 中发生,但未在用户代码中进行处理 其他信息: T ...
- ubuntu下安装TexLive和Texmaker
也可以参考ubuntu14.04配置中文latex完美环境(texlive+texmaker+lyx) 设置中文字体的时候参考ubuntu 下安装 texlive 并设置 ctex 中文套装 1.首先 ...