Surveillance Cameras
InterviewTime limit4sMemory limit512 MB
Choose the fewest circular arcs that cover all N rooms on a circle, or report impossible.
Problem
N rooms sit on a circle. K cameras each watch a contiguous arc, possibly wrapping: if then rooms through ; if then rooms through and through N.
Find the minimum number of cameras needed to watch every room. Print impossible if it cannot be done.
Input
- Line 1: , .
- Next lines: , .
Output
Minimum number of cameras, or impossible.