Woburn Challenge 2018-19 Round 1 - Senior Division
It's time for Bob to face his biggest fear at H.S. High School: the
dreaded gym class rope climb. In this brutal test of strength and
endurance, Bob is tasked with ascending part of the way up an infinitely
long vertical rope. He begins by grabbing onto the bottom of the rope,
at a height of 0, and must reach any height of
To make matters even worse than usual, Alice has pranked Bob by
spreading itching powder on some sections of the rope, which he'll need
to avoid along the way! She's done so for
Bob's rope-climbing style is… unusual, to say the least, which may come
in handy for avoiding Alice's itching powder. At any point, given that
he's currently holding onto the rope at some height
- Jump upwards by a height of exactly
, such that his new height is , but only if the rope is not covered in itching powder at height . - Drop downwards by any height, such that his new height is any
integer
, but only if the rope is not covered in itching powder at height .
Both types of actions involved in this technique are understandably
quite tiring, so Bob would like to avoid performing more of them than
necessary. Help him determine the minimum number of actions he must
perform to reach a height of at least
Subtasks
In test cases worth 8/27 of the points,
In test cases worth another 12/27 of the points,
Input Specification
The first line of input consists of three space-separated integers,
Output Specification
Output a single integer, either the minimum number of actions required
for Bob to reach a height of at least -1
if it's
impossible for him to do so.
Sample Input 1
12 5 2
2 4
10 10
Sample Output 1
5
Sample Input 2
5 2 2
1 1
4 4
Sample Output 2
-1
Sample Explanation
In the first case, Bob can jump up to a height of
In the second case, Bob must start by jumping up to a height of
Comments