14995 - The Dungeon Trial   

Description

You enter a perilous dungeon equipped with initial HP, gold, and keys. To escape, you must clear three rooms in sequential order:

Room 1 -- The Guard:

  • If your HP is greater than 50, you defeat the guard but take damage: lose 20 HP and gain 10 gold.
  • Otherwise, you sneak past carefully: lose 10 Hp and gain 5 gold.

Room 2 -- The Treasure Room:

  • If your new gold is at least 30, you unlock a hidden vault: spend 30 gold and gain 1 key.
  • Otherwise, you only find scattered loose change: gain 10 gold and lose 5 HP.

Room 3 -- The Locked Door:

  • If you have at least 1 key and your current HP is greater than 30, you unlock the exit: use 1 key and gain 50 gold.
  • Otherwise, you are forced to break the door down by brute force: lose 10 HP.

Write a program to calculate and output your final stats (HP, gold, and keys) after clearing all three rooms.

Note that HP cannot go below 0. If your final HP is negative, set it to 0.

Input

The input consists of three integers representing your initial HP, gold, and keys, provided on separate lines.

Constraints:

  • 1 <= HP <= 100
  • 1 <= gold <= 100
  • 0 <= keys <= 10

 

  • Testcases 1, 2, 3: 1 <= HP <= 50, 1 <= gold < 30, 0 <= keys <= 10
  • Testcases 4, 5: 1 <= HP <= 100, 1 <= gold <= 100, 0 <= keys <= 10

Output

Output your final HP, gold, and keys, each separated by a line.

Sample Input  Download

Sample Output  Download

Tags




Discuss