| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 283 | 195 | 160 | 68.966% |
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 $N$ (1ドル≤N≤10^5$). The following $N$ lines consist of 2ドル$ integers $M$ (0ドル≤M<2^{31}$) and $O$ ($O\in\{0,1\}$), where $M$ is the time this recording was taken in milliseconds, and $O$ denotes whether the LED was on or off. The number 1ドル$ corresponds to the LED being on, and 0ドル$ off.
Output a single integer denoting the time of the first recording where the LED was off, or output $-1$ if it was never off for any recording.
4 400 0 100 1 300 0 200 1
300
3 10 1 2010 1 150 1
-1
6 250 0 25 1 100 0 50 0 200 1 150 1
50
University > University of Alberta Programming Contest > UAPC 2025 > Division 2 B번