Battle
| Time limit:2000 ms |
|
Memory limit:131072 K |
| Total submissions:1851 |
|
Accepted:455 |
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 haveH1 hit points (HP) at the beginning of the battle, and Heilong hasH2. Heilong attacks you each time you do an action, and dealAIPoints of damage inI-Th round. You have three kinds of actions.
- Attack. You attack Heilong, and doXPoints of damage.
- Defend. You focus on avoiding the attack of Heilong. This action nullifies Heilong's attack in this round.
- Heal. You heal yourself, addingYHit 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 dragonNRounds, 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 or less 109. Then followNLines,ITh line contains one integerAI-1. 1 ≤AI-1 ≤ 104.
Output
If you can kill Heilong, the first line of your output shocould 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 14 1 1 3 3110110
Sample Input 24 1 1000 1 411011
Sample output
Sample Output 1Win4
Sample Output 2Lose3
Hint
In sample 1, you have to defend in the 2nd round, othewise you will die.
In sample 2, you heal yourself in the first round, and keep attacking
N Rounds expires.
Source
Poj monthly -- 2007.11.25, Yang Yi indicates that zhurengong has Heilong, zhurengong has H1 blood, Heilong has H2 blood, And zhurengong has fixed damage, the damage of Heilong is not fixed. Zhurengong can choose to attack, defend against, and accumulate blood. Note that the attack and blood will lose blood. The greedy strategy was adopted. After the first fight, the most painful one was abandoned until it was not killed.
#include <iostream>#include <cstdio>#include <queue>using namespace std;int a[123456];int main(){ int n,x,y,me,hl; int i; while(scanf("%d%d%d%d%d",&n,&x,&y,&me,&hl)!=EOF){ priority_queue<int> pq; int hit=0,mhit=0; for(i=1;i<=n;i++){ scanf("%d",&a[i]); } for(i=1;i<=n;i++){ hit++; mhit=max(hit,mhit); if(hit*x>=hl)break; me-=a[i]; pq.push(max(a[i],y)); //cout<<me<<" "<
Poj3465 (Greedy + priority queue)