#K79767. Minimum Delivery Time for Circular Zones
Minimum Delivery Time for Circular Zones
Minimum Delivery Time for Circular Zones
In this problem, two delivery drones start from different zones on a circular track consisting of N zones. The goal is to compute the minimum time required for the two drones to meet. Drones can move in either clockwise or counter-clockwise directions.
Given the starting positions P1 and P2 of the drones, the effective travel time is the minimum of the clockwise distance and the counter-clockwise distance.
Mathematically, if we denote the distances as:
Then, the answer is:
inputFormat
The input consists of a single line containing three space-separated integers:
N
(the number of zones arranged in a circle)P1
(the starting zone of the first drone)P2
(the starting zone of the second drone)
It is guaranteed that N >= 1
and 1 <= P1, P2 <= N
.
outputFormat
Output a single integer representing the minimum time required for the two drones to meet.
## sample5 1 1
0