ZOJ 3623 Battle Ships 简单DP
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3623
题意:给出N种可以建造的船和对方的塔生命值L,每种船给出建造时间t[i]和每秒输出dps[i],船坞在同一时间仅仅能建造一支船(类似红警),问多少时间以后可以灭掉塔。
思路:dp[i]代表的是在前i秒内能造成的伤害量,把时间反过来考虑,对于每支船的建造,在前i秒内所占用的建造时间是第i-t[i]+1~i秒,状态转移方程是dp[i+t[j]]=max(dp[i+t[j]],dp[i]+dps[j]*i),因为建设船的时间是第i~t[i]+1~i秒,所以在状态转移时不会出现建设时间的重叠情况。
P.S.比赛的时候不机智了,题意里的each time被我理解成了每秒能够选择造一艘新的船。
代码:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define eps 1e-8
#define INF 0x7fffffff
#define maxn 10005
#define PI acos(-1.0)
#define seed 31//131,1313
typedef long long LL;
typedef unsigned long long ULL;
using namespace std;
int t[35],dps[35];
int dp[355];
int main()
{
int N,L;
while(~scanf("%d%d",&N,&L))
{
memset(dp,0,sizeof(dp));
for(int i=0;i<N;i++)
scanf("%d%d",&t[i],&dps[i]);
for(int i=0;i<=L+20;i++)
for(int j=0;j<N;j++)
dp[i+t[j]]=max(dp[i+t[j]],dp[i]+dps[j]*i);
for(int i=0;i<=L+20;i++)
if(dp[i]>=L)
{
printf("%d\n",i);
break;
}
}
return 0;
}
ZOJ 3623 Battle Ships 简单DP的更多相关文章
- ZOJ 3623 Battle Ships DP
B - Battle Ships Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Subm ...
- [ZOJ 3623] Battle Ships
Battle Ships Time Limit: 2 Seconds Memory Limit: 65536 KB Battle Ships is a new game which is s ...
- ZOJ 3349 Special Subsequence 简单DP + 线段树
同 HDU 2836 只不过改成了求最长子串. DP+线段树单点修改+区间查最值. #include <cstdio> #include <cstring> #include ...
- Codeforces 567D One-Dimensional Battle Ships
传送门 D. One-Dimensional Battle Ships time limit per test 1 second memory limit per test 256 megabytes ...
- ZOJ3623:Battle Ships(全然背包)
Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense ...
- Battle Ships(复习泛化物品**)
传送门Battle Ships Time Limit: 2 Seconds Memory Limit: 65536 KB Battle Ships is a new game which i ...
- zoj3623 Battle Ships
Battle Ships is a new game which is similar to Star Craft. In this game, the enemy builds a defense ...
- HDU 1087 简单dp,求递增子序列使和最大
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- Codeforces Round #Pi (Div. 2) D. One-Dimensional Battle Ships set乱搞
D. One-Dimensional Battle ShipsTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...
随机推荐
- PHP Html 弹窗,本页面弹窗子页面
echo '<script type=text/javascript>window.open("","name1","width=100, ...
- c语言移位操作
应该先看看C语言是指所有的位二进制算术位计算.即使输入的是十进制的数,在存储器存储为二进制形式. “<<”使用方法: 的格式是:a<<m,a和m式,要求m>=0. 功能: ...
- UML序列图总结(转)
序列图主要用于展示对象之间交互的顺序. 序列图将交互关系表示为一个二维图.纵向是时间轴,时间沿竖线向下延伸.横向轴代表了在协作中各独立对象的类元角色.类元角色用生命线表示.当对象存在时,角色用一条虚线 ...
- 正确Linux新手很实用20命令
//正确Linux新手很实用20命令 //slwang 2014.4.19 1, ls list directory contents 内容 ls -l //以详情模式(long li ...
- Windows Phone 8 - 建立App专属联络人资讯(ContactStore)
原文:Windows Phone 8 - 建立App专属联络人资讯(ContactStore) 在WP7的时候介绍了如何操作联络人的功能,例如:<Windows Phone 7 - 存取联络人与 ...
- Swing中弹出对话框的几种方式(转)
http://www.cnblogs.com/mailingfeng/archive/2011/12/28/2304289.html 在swing中,基于业务的考量,会有对话框来限制用户的行为及对用户 ...
- HDU 2815 Mod Tree 离散对数 扩张Baby Step Giant Step算法
联系:http://acm.hdu.edu.cn/showproblem.php?pid=2815 意甲冠军: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQ ...
- CareerCup Chapter 4 Trees and Graphs
struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),rig ...
- 我只是不甘心-------Day51
回放假回家一天,完全断网,天气也很给力配合.水蓝色的天空.白云,抬眼,我没有看到刺目的光芒,但仍眼眼睛刺痛.已经缩小眼,我试图打开眼睛,就像眼泪都流出来了,它不会擦到沙,这是很多其他的没地方. 哥哥去 ...
- A左右ndroid正在使用Uri监视数据库中的更改
在监控数据库在线原创文章是非常小的变化,基本上没有找到一个实际的问题.所以,如果你看到一个有点蓝牙源代码,写一个Demo.在这里,供大家参考,查看源代码: src有三个文件MyDataProvider ...