Woburn Challenge 2018-19 Round 2 - Junior Division
The IMF (Impossible Mission Force) has gotten wind of a vile plot by escaped convict Solomon Lane to poison Toronto's entire supply of maple syrup! They've dispatched their best agent, Ethan Hunt, to put a stop to this.
Ethan has learned that Solomon will be meeting with a poison supplier
somewhere in the CN Tower, which has
Fortunately, he's got the high-tech gadgets for the job. Without a
second thought, Ethan has found himself cutting through a window and
clinging to the exterior of the tower at floor
What's the minimum amount of glove energy required for Ethan to gain
access to floor
Input Specification
The first line of input consists of a single integer,
The second line consists of a single integer,
The third line consists of a single integer,
The fourth line consists of a single integer,
Output Specification
Output a single integer, the minimum amount of energy (in joules)
required for Ethan to climb from floor
Sample Input 1
40
39
4
5
Sample Output 1
5
Sample Input 2
142
147
9
12
Sample Output 2
45
Sample Explanation
In the first case, Ethan must climb downwards by
In the second case, Ethan must climb upwards by
Comments