#C7676. Contiguous Winning Subsequence

    ID: 51573 Type: Default 1000ms 256MiB

Contiguous Winning Subsequence

Contiguous Winning Subsequence

Alice and Bob are playing a series of games. In each game, both of them receive a score. A game is considered a win for Alice if her score is strictly greater than Bob's score. A contiguous subsequence is a set of consecutive games from the series. Your task is to determine if there exists any contiguous subsequence in which Alice wins every game in that subsequence. Note that a single game is considered a contiguous subsequence.

Mathematically, given $n$ games with scores $(a_1, b_1), (a_2, b_2), \dots, (a_n, b_n)$, you need to check if there exists indices $i$ and $j$ ($1 \leq i \leq j \leq n$) such that for every game $k$ in the subarray, $a_k > b_k$. Since a subsequence of length $1$ qualifies, the problem reduces to determining whether there is at least one game for which $a_k > b_k$.

inputFormat

The first line of input contains a single integer $n$ ($1 \leq n \leq 10^5$), representing the number of games.

Each of the following $n$ lines contains two space-separated integers $a$ and $b$ ($0 \leq a, b \leq 10^9$), which represent the scores of Alice and Bob respectively for that game.

You should read the input from standard input (stdin).

outputFormat

Output a single line containing the string YES if there exists any contiguous subsequence (of at least one game) where Alice's score is strictly greater than Bob's score in every game. Otherwise, output NO.

The output should be written to standard output (stdout).

## sample
5
10 8
15 14
25 24
30 29
35 33
YES