Time Limit: 2000MS | Memory Limit: 131072K | |
Total Submissions: 2196 | Accepted: 564 |
Description
You're Zhu Rengong, a formidable hero. After a number of challenging missions, you are finally facing the final Boss – a black dragon called Heilong. Due to his overwhelming power, you have to plan your actions carefully.
You have H1 hit points (HP) at the beginning of the battle, and Heilong has H2. Heilong attacks you each time you do an action, and deal Ai points of damage in the i-th round. You have three kinds of actions.
- Attack. You attack Heilong, and do x points of damage.
- Defend. You focus on avoiding the attack of Heilong. This action nullifies Heilong's attack in this round.
- Heal. You heal yourself, adding y hit points to yourself. There is no upper bound on your HP.
If anyone's HP drop below or equal to 0, he dies. If you can't kill the dragon within N rounds, you will also die. So you need to know how many rounds you need to kill the black dragon. If you cannot kill him, you will have to calculate the maximal damage you can do on Heilong.
Input
The first line contains five integers, N, x, y, H1, H2. 1 ≤ N ≤ 105, 1 ≤ x,y ≤ 104, 1 ≤ H1,H2 ≤ 109. Then follow N lines, the ith line contains one integer Ai-1. 1 ≤ Ai-1 ≤ 104.
Output
If you can kill Heilong, the first line of your output should be "Win". Otherwise "Lose".
The second line contains the number of rounds you need to kill Heilong if the first line is "Win", or the maximal damage you can do if the first line is "Lose".
Sample Input
Sample Input 1 4 1 1 3 3 1 10 1 10
Sample Input 2 4 1 1000 1 4 1 10 1 1
Sample Output
Sample Output 1 Win 4
Sample Output 2 Lose 3
Hint
In Sample 2, you heal yourself in the first round, and keep attacking until N rounds expires.
题意:
剑圣在单挑大龙
剑圣每一次放技能龙就会打他一下,剑圣就三个技能:
1 对龙攻击造成减少X点血
2 躲掉龙的攻击
3 回血Y点
龙N次攻击造成减少血量为 ai
初始状态下剑圣和龙的血量分别是 H1 H2
问剑圣是否可以solo过大龙,并输出相应的数据
题解:
每一次都攻击大龙,直到剑圣要死了,时光倒流,选择前面某一次进行回血或者躲避大龙的攻击
也就是说贪心攻击,时光倒流的时候用优先队列选择即可
#include<queue>
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int n,x,y,h1,h2;
priority_queue<int>que;
//freopen("in.txt","r",stdin);
while(scanf("%d%d%d%d%d",&n,&x,&y,&h1,&h2)!=EOF)
{
while(!que.empty())
que.pop();
int t,k,sum=0,flag=0,ans=-1;
for(int i=1;i<=n;i++){
scanf("%d",&t);
if(h2<=0||h1<=0)
continue;
h1-=t,h2-=x,sum+=x;
ans=max(ans,sum);
que.push(max(y,t));
if(h2<=0){
flag=i;
continue;
}
while(h1<=0&&(!que.empty()))
{
k=que.top();
que.pop();
sum-=x;
h2+=x;
h1+=k;
}
}
if(flag){
puts("Win");
printf("%d\n",flag);
}
else{
puts("Lose");
printf("%d\n",ans);
}
}
return 0;
}