Cheater Search
InterviewTime limit2sMemory limit1024 MB
Find a contiguous cheater interval [l, r] so that cheaters' claimed ranges avoid it and every non-cheater's claimed range overlaps it.
- Level
Medium6 of 10
- Topics
- Two pointers, Prefix sum, Array
- Solved
- No attempts yet
Problem
There are pidols numbered from to , all distinct. Some of them are cheaters, and their numbers are consecutive. Specifically, for some integers , , pidols through are all cheaters, and every other pidol is not a cheater.
Pidol claims that at least one cheater is among the pidols numbered from to inclusive. If pidol is not a cheater, the claim is true. However, all cheaters lie. That is, if pidol is a cheater, then no cheater is among the pidols numbered to .
Input
The first line contains the number of pidols .
Each of the next lines contains two integers and , separated by a space. The line gives the claim of pidol , that at least one cheater is among the pidols numbered from to .
Output
Print two integers and separated by a space, a valid pair that satisfies all the claims. If several answers exist, print any one of them.