LCC '25 Contest 1 J2 - Threatening Treats
View as PDFIn the spirit of Halloween, Johnny decides to go trick-or-treating. Unfortunately, he ventures into a rather shady neighborhood. When Johnny returns home, he eagerly eats all the candies he collected, one by one in the order he obtained them. Each candy can either increase or decrease his health point by a certain amount
. Johnny begins with
health points (HP).
If at any point during his candy feast Johnnys HP drops to or below, he sadly does not survive the night.
Determine whether Johnny survives after eating all the candies.
Input Specification
The first line contains two integers, and
— the number of candies and Johnnys starting HP.
The next lines each describe a candy in the form:
BOOST X, which increases Johnnys HP by integer,
DAMAGE X, which decreases Johnnys HP by integer.
All values of are positive integers.
Output Specification
If he survives, on a single line, output Johnny will return next year!.
Otherwise, output Johnny is cooked!.
Subtasks
Subtasks 1 [50%]
Subtasks 2 [50%]
Sample Input 1
3 1
BOOST 3
DAMAGE 2
BOOST 1
Output for Sample Input 1
Johnny will return next year!
Explanation of Output for Sample Input 1
Johnny begins with HP. He then eats a candy that gives him
HP, resulting in
HP. He then eats a candy that damages his health by
HP, resulting in
HP. Finally he eats the last candy which results in him ending with
HP.
Sample Input 2
6 1
BOOST 5
DAMAGE 4
BOOST 9
BOOST 3
DAMAGE 15
BOOST 7
Output for Sample Input 2
Johnny is cooked!
Comments