1334A.md (3338B)
1 Source: https://codeforces.com/problemset/problem/1334/A 2 3 A. Level Statistics 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Polycarp has recently created a new level in this cool new game Berlio Maker 85 and uploaded it online. Now players from all over the world can try his level. 22 23 All levels in this game have two stats to them: the number of plays and the number of clears. So when a player attempts the level, the number of plays increases by $1$. If he manages to finish the level successfully then the number of clears increases by $1$ as well. Note that both of the statistics update at the same time (so if the player finishes the level successfully then the number of plays will increase at the same time as the number of clears). 24 25 Polycarp is very excited about his level, so he keeps peeking at the stats to know how hard his level turns out to be. 26 27 So he peeked at the stats $n$ times and wrote down $n$ pairs of integers — $(p_1, c_1), (p_2, c_2), \dots, (p_n, c_n)$, where $p_i$ is the number of plays at the $i$-th moment of time and $c_i$ is the number of clears at the same moment of time. The stats are given in chronological order (i.e. the order of given pairs is exactly the same as Polycarp has written down). 28 29 Between two consecutive moments of time Polycarp peeked at the stats many players (but possibly zero) could attempt the level. 30 31 Finally, Polycarp wonders if he hasn't messed up any records and all the pairs are correct. If there could exist such a sequence of plays (and clears, respectively) that the stats were exactly as Polycarp has written down, then he considers his records correct. 32 33 Help him to check the correctness of his records. 34 35 For your convenience you have to answer multiple independent test cases. 36 37 Input 38 39 The first line contains a single integer $T$ $(1 \le T \le 500)$ — the number of test cases. 40 41 The first line of each test case contains a single integer $n$ ($1 \le n \le 100$) — the number of moments of time Polycarp peeked at the stats. 42 43 Each of the next $n$ lines contains two integers $p_i$ and $c_i$ ($0 \le p_i, c_i \le 1000$) — the number of plays and the number of clears of the level at the $i$-th moment of time. 44 45 Note that the stats are given in chronological order. 46 47 Output 48 49 For each test case print a single line. 50 51 If there could exist such a sequence of plays (and clears, respectively) that the stats were exactly as Polycarp has written down, then print "YES". 52 53 Otherwise, print "NO". 54 55 You can print each letter in any case (upper or lower). 56 57 Example 58 59 Input 60 61 ``` 62 6 63 3 64 0 0 65 1 1 66 1 2 67 2 68 1 0 69 1000 3 70 4 71 10 1 72 15 2 73 10 2 74 15 2 75 1 76 765 432 77 2 78 4 4 79 4 3 80 5 81 0 0 82 1 0 83 1 0 84 1 0 85 1 0 86 ``` 87 88 Output 89 90 ``` 91 NO 92 YES 93 NO 94 YES 95 NO 96 YES 97 ``` 98 99 Note 100 101 In the first test case at the third moment of time the number of clears increased but the number of plays did not, that couldn't have happened. 102 103 The second test case is a nice example of a Super Expert level. 104 105 In the third test case the number of plays decreased, which is impossible. 106 107 The fourth test case is probably an auto level with a single jump over the spike. 108 109 In the fifth test case the number of clears decreased, which is also impossible. 110 111 Nobody wanted to play the sixth test case; Polycarp's mom attempted it to make him feel better, however, she couldn't clear it.