Testing LEDs
시간 제한2초메모리 제한2048 MB
타임스탬프와 LED 상태를 담은 기록 N개가 주어질 때, 상태가 꺼짐인 기록 중 가장 이른 시각을 출력하고, 꺼진 기록이 없으면 -1을 출력한다.
문제
LEDs are an amazing technology, in part due to their longevity. But they can’t last forever right? So you decide to put it to the test; you turn on an LED, and a machine periodically records the time in milliseconds since you started. Eventually it turns off! Your machine kept recording though, and unforunately your data is all jumbled up! What is the first time the machine recorded the LED being off?
Note that the LED may turn back on; you want to find the very first time the LED was recorded being off.
입력
The first line of input contains the integer (). The following lines consist of integers () and (), where is the time this recording was taken in milliseconds, and denotes whether the LED was on or off. The number corresponds to the LED being on, and off.
출력
Output a single integer denoting the time of the first recording where the LED was off, or output if it was never off for any recording.