编程介的小学生 2019-08-06 21:57 采纳率: 20.5%
浏览 132

JRY is Fighting,这个问题用C语言的正确地实现

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 get k 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 as s, 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, let T=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 sequence s which is right for the hero to survive successfully. The hero is so strict that you should find the lexicographically smallest one.

Sequence u1,u2,⋯,un is lexicographically smaller than sequence v1,v2,⋯,vm, if

n<m and u1=v1,u2=v2,⋯,un=vn, or

there exists an integer k(1≤k≤min(n,m)) where u1=v1,u2=v2,⋯,uk−1=vk−1 and uk<vk all hold.

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 contains n space-separated integers, ai(0≤|ai|≤100).

Output
If the hero can't survive, print "Poor Hero!".
If T=+∞, print "Poor JRY!".
Otherwise, print three lines:
The first line, an integer, representing the value of T.
The second line, an integer, |s|.
The third line, |s| space-separated intergers, si.

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!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大