JRY is Fighting
Time Limit: 3000 ms
Memory Limit: 65536 KiB
Problem Description
Long long ago, there is a hero fighting against the emperor JRY. At the very beginning, the hero has m HPs(health-points). There points represent his health - if ever they fall below or equal to zero, the hero will die. In the following n seconds, he will be hurt by XXY. At the i seconds, his HP will reduce by hi . If hi<0 , it means his HP will increase by |hi| .
The hero has a magic bottle which can store HPs. At first, the bottle is empty. Each time after the hero got hurt, the bottle can getk more HPs, and the hero can decide whether he will release the HPs in the bottle. If he does, he will gain the HPs in the bottle and the bottle will be empty.
We define the hero\'s operating sequence ass , representing that he used the magic bottle at the si -th seconds. |s| represent the times he used, as well as the length of the sequence.
Now, you should maximize the mininum time interval between two adjacent operation. In other words, letT=max{min{si−si−1}(1<i≤|s|)} , you should find the value of T . We can easily find that if |s|≤1 , T=+∞ .
You should give him a plan as an operating sequences which is right for the hero to survive successfully. The hero is so strict that you should find the lexicographically smallest one.
Sequenceu1,u2,⋯,un is lexicographically smaller than sequence v1,v2,⋯,vm , if
n<m and u1
The hero has a magic bottle which can store HPs. At first, the bottle is empty. Each time after the hero got hurt, the bottle can get
We define the hero\'s operating sequence as
Now, you should maximize the mininum time interval between two adjacent operation. In other words, let
You should give him a plan as an operating sequence
Sequence
Input
There are multiple testcases, the sum of n is less then 106 .
The first line contains three space-separated integers each,n(1≤n≤500000) , m(1≤m≤106) , k(1≤k≤100) .
The second line containsn space-separated integers, ai(0≤|ai|≤100) .
The first line contains three space-separated integers each,
The second line contains
Output
If the hero can\'t survive, print "Poor Hero!".
IfT=+∞ , print "Poor JRY!".
Otherwise, print three lines:
The first line, an integer, representing the value ofT .
The second line, an integer,|s| .
The third line,|s| space-separated intergers, si .
If
Otherwise, print three lines:
The first line, an integer, representing the value of
The second line, an integer,
The third line,
Sample Input
5 7 3 1 -2 10 2 2 2 33 33 -33 -33 1 1 1 1
Sample Output
2 2 1 3 Poor JRY! Poor Hero!
Hint
Case 1 : At second 1, hero\'s HP are 7−1=6 , bottle has 3 HP, hero used the bottle, hero\'s HP are 6+3=9 , bottle has 0 HP. At second 2, hero\'s HP are 9+2=11 , bottle has 3 HP. At second 3, hero\'s HP are 11−10=1 , bottle has 3+3=6 HP, hero used the bottle, hero\'s HP are 1+6=7 , bottle has 0 HP. At second 4, hero\'s HP are 7−2=5 , bottle has 3 HP. At second 5, hero\'s HP are 5−2=3 . Hero escaped successfully with T=2,s1=1,s2=3 . Case 2 : Anyhow, hero can survive without using the bottle. So T=+∞ . Case 3 : Anyhow, hero\'s HP will be zero in chamber 1. So he can\'t survive.
Source
2015 Multi-University Training Contest 2