HDU3646Fate Stay Night动态规划DP题解

Fate Stay Night

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 278    Accepted Submission(s): 73

Problem Description
Jack was addicted to a fighting game recently. The game is similar to a famous anime “Fate Stay Night”. In the game, you should control your “servant” Saber to fight another “servant” Berserker.

Berserker is a famous hero who has a lot of lives. In every life, he has some “blood points”. For example, he may have 100 blood points in his first life and 200 blood points in his second life. When Berserker loss all blood points in a life, he is killed. But he will become alive immediately with next life. When there is no next life left, Berserker is really dead and you win.
Saber can attack Berserker for N times. During each attack, Saber releases a fire bird to fight Berserker. Each fire bird has some “power points”.
A fire bird can make Berserker loss blood points. But if Berserker loss one blood point, the fire bird also will loss one power point. When the power points of a fire bird become zero, the fire bird dies.
A living fire bird may be in two statuses:“young”or “old”.
When a fire bird is just released, it is “young”. After it kills Berserker once or more, it becomes“old”.
Let’s suppose a fire bird with remaining n power points fighting Berserker with remaining m blood points in his current life:
If n> m: Berserker will be killed and becomes alive immediately with his next life(if he has), and then the fire bird will be“old”and fight Berserker again with remaining n-m power points.

If n = m: Berserker will be killed and becomes alive with his next life (if he has), and the fire bird dies.

If n < m: In this situation, if the fire bird is “young”, it will die after making Berserker loss n blood points. But if the fire bird is “old”, it just dies without doing any harm to Berserker.

As the “Master” of Saber, you can use “Command Mantra” M times. You can use “Command Mantra”to double a fire bird’s power points, but you can’t use “Command Mantra”more than once on a same fire bird. Now there is the question: How many times can you kill Berserker at most?

 

 

Input
There are several data cases, ended with “0 0 0”
For each test case:
The first line contains three integers N,M,K, meaning the number of attacks of Saber, the times of Command Mantra you can use and the number of lives of Berserker.
The second line contains N integers, indicating the power points of N fire birds, in the order of attacking. You can’t change the attacking order.

The third line contains K integers, meaning the blood points of all Berserker’s lives. The first integer is for his first life, the second integer is for his second life, etc.
Please note: 1<=N<=10000, 0<=M<=100, 0<=K<=100000. All power points and blood points are no more than 10000 and none negative.

 

 

Output
For each test case, output one line containing the maximum times that you can kill Berserker.
 

 

Sample Input
  
  
10 0 20 8 9 8 7 5 7 5 5 0 2 3 0 2 1 7 1 5 5 7 0 6 1 5 6 7 3 1 0 5 8 10 1 0 6 0 0 7 7 7 1 7 6 7 0 0 0
 

 

Sample Output
  
  
12 0
 

 

Source
 

 

Recommend
lcy
区域赛杭州网络赛第6题
昨天这题如果AC,我们就有希望晋级现场赛
可是我杯具地把s数组开小了,导致WA
如果返回RE的话我就能发现
WA无数次后也有发现b数组开小了,却忘了改s数组
我实在是蒟蒻!
整个网络赛我们都很杯具,主要是我们实力弱
再加上只有我们三个带领刚进集训队的几个学弟做比赛
老队员都不在
现在只有天津出线了
最后一站福州赛区,老队员回来了,我们压力就应该小些
最后一次机会一定要好好把握!
这道DP其实很简单的
状态:
d[i][j]表示第i只fire Bird使用j次Command Mantra能造成的最大伤害
最后根据最大伤害算出Kill Times
状态转移方程:
d[i][j]=max(d[i-1][j]+w(1),d[i-1][j-1]+w(2));
w(1)表示不使用Command Mantra能造成的最大伤害
w(2)表示使用一次Command Mantra能造成的最大伤害
根据上一次的伤害值算出Berserker处于第几次生命以及剩下的生命值
边界:
d[i][0]=d[i-1][0]+w(1);
代码:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值