#P5639. Minimum Time to Evade the Surveillance
Minimum Time to Evade the Surveillance
Minimum Time to Evade the Surveillance
In this problem, Small Z needs to reach the takeout delivery point (the second gate) without being seen by the surveillance cameras. The school has installed a row of cameras along the only path from the dormitory to the delivery point. Due to limited funding, the cameras only work for $1$ second then pause for $1$ second, alternating continuously. Formally, at time intervals $[0,1)$ they are ON, at $[1,2)$ they are OFF, then ON at $[2,3)$, OFF at $[3,4)$, and so on.
Small Z has mastered a sprint skill so that whenever he runs through a sequence of cameras that are off, regardless of the number of cameras he passes, it always takes him exactly $1$ second. However, if any camera is active he cannot pass safely. In other words, his entire run must occur during an OFF period of the cameras.
Assume the input is a single integer n
representing the number of cameras along the route. If n = 0
, there are no cameras, and Small Z can immediately reach the destination (time = 0). Otherwise, if n ≥ 1
, he must wait until the cameras turn OFF. Since the cameras start in the ON phase during $[0,1)$, the earliest safe time to begin his run is at time $1$, and his sprint will then take exactly $1$ second. Hence, the minimum time required is $1 + 1 = 2$ seconds.
Your task is to compute and output the minimum time required based on the given input.
inputFormat
The input consists of a single integer n
on one line. n
represents the number of surveillance cameras along the route. It is guaranteed that n ≥ 0
.
If n = 0
, there are no cameras.
outputFormat
Output a single integer representing the minimum time (in seconds) required for Small Z to safely reach the takeout delivery point.
Note: If n = 0
, output 0; otherwise, output 2.
sample
0
0