Elevators in c program

, ,

Jojo likes to use elevator while being at a building. On his father’s office, there are 3
identical elevators (which have same velocity 1 level/second).
Unfortunately, one of those elevators is in maintenance. Then, when Jojo sees those two
elevators, the first one is on the x
th floor going up and the second one is on the y
th floor
and is going down. The third elevator (which in maintenance) is recently on the k
th floor.
Jojo is wondering if those three elevators will be in the same level or not.
input :
Input consists of 3 integers x, y, k, the position of the first, second, and third elevator,
output :
Output a line consists of t which describe the time when the three elevators are on the
same levels. If this event is impossible to happen, output -1.
constrain :
0 ≤ x, y, k ≤ 100
All floor numbers is available (no floor number is withdrawn, like 4, 13, etc.)
sample input 1 :
3 5 4
output 1 :
sample input 2 :
1 2 5
output 2 :
please help me on this problem