CF1334A.Level Statistics

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

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 11. If he manages to finish the level successfully then the number of clears increases by 11 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).

Polycarp is very excited about his level, so he keeps peeking at the stats to know how hard his level turns out to be.

So he peeked at the stats nn times and wrote down nn pairs of integers — (p1,c1),(p2,c2),…,(pn,cn)(p_1, c_1), (p_2, c_2), \dots, (p_n, c_n), where pip_i is the number of plays at the ii-th moment of time and cic_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).

Between two consecutive moments of time Polycarp peeked at the stats many players (but possibly zero) could attempt the level.

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.

Help him to check the correctness of his records.

For your convenience you have to answer multiple independent test cases.

Polycarp 最近在这款酷炫的新游戏 Berlio Maker 85 中创建了一个新关卡,并将其上传至网络。现在,全世界的玩家都可以尝试他设计的关卡。

该游戏中的所有关卡均具有两个统计指标:尝试次数(plays) 和 通关次数(clears)。当一名玩家尝试该关卡时,尝试次数增加 11;若他成功通关,则通关次数也同时增加 11。注意:这两个统计值是同步更新的(即若玩家成功通关,则尝试次数与通关次数在同一时刻各自增加 11)。

Polycarp 对自己设计的关卡非常兴奋,因此他不断查看统计数据,以了解该关卡的实际难度。

于是,他共查看了 nn 次统计数据,并记下了 nn 对整数:(p1,c1),(p2,c2),…,(pn,cn)(p_1, c_1), (p_2, c_2), \dots, (p_n, c_n),其中 pip_i 表示第 ii 次查看时刻的尝试次数,cic_i 表示同一时刻的通关次数。这些统计数据按时间顺序给出(即所给数对的顺序与 Polycarp 记录的顺序完全一致)。

在两次连续查看之间,可能有(也可能没有)多名玩家尝试了该关卡。

最后,Polycarp 想知道自己的记录是否全部准确无误。若存在某个合法的玩家尝试(及通关)序列,使得各时刻的统计数据恰好与 Polycarp 所记录的一致,则他认为这些记录是正确的。

请你帮他验证这些记录的正确性。

为方便起见,你需要处理多个相互独立的测试用例。

输入格式

The first line contains a single integer TT (1≤T≤500)(1 \le T \le 500) — the number of test cases.

The first line of each test case contains a single integer nn (1≤n≤1001 \le n \le 100) — the number of moments of time Polycarp peeked at the stats.

Each of the next nn lines contains two integers pip_i and cic_i (0≤pi,ci≤10000 \le p_i, c_i \le 1000) — the number of plays and the number of clears of the level at the ii-th moment of time.

Note that the stats are given in chronological order.

第一行包含一个整数 TT(1≤T≤5001 \le T \le 500)——测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤1001 \le n \le 100)——Polycarp 查看统计数据的时刻数量。

接下来的 nn 行中,每行包含两个整数 pip_i 和 cic_i(0≤pi,ci≤10000 \le p_i, c_i \le 1000)——第 ii 个时刻该关卡的游玩次数和通关次数。

注意:统计数据按时间顺序给出。

输出格式

For each test case print a single line.

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".

Otherwise, print "NO".

You can print each letter in any case (upper or lower).

对每个测试用例,输出一行。

如果存在这样一系列操作(包括“播放”和相应的“清除”),使得统计结果恰好与 Polycarp 记录的一致,则输出 "YES"。

否则,输出 "NO"。

字母大小写均可(即可以全部大写或全部小写)。

输入输出样例

  • 输入#1

    6
    3
    0 0
    1 1
    1 2
    2
    1 0
    1000 3
    4
    10 1
    15 2
    10 2
    15 2
    1
    765 432
    2
    4 4
    4 3
    5
    0 0
    1 0
    1 0
    1 0
    1 0

    输出#1

    NO
    YES
    NO
    YES
    NO
    YES

说明/提示

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.

The second test case is a nice example of a Super Expert level.

In the third test case the number of plays decreased, which is impossible.

The fourth test case is probably an auto level with a single jump over the spike.

In the fifth test case the number of clears decreased, which is also impossible.

Nobody wanted to play the sixth test case; Polycarp's mom attempted it to make him feel better, however, she couldn't clear it.

在第一个测试用例中,第三时刻的通关次数增加了,但播放次数却没有增加,这是不可能发生的。

第二个测试用例是一个“超级专家”难度关卡的典型示例。

在第三个测试用例中,播放次数减少了,这是不可能的。

第四个测试用例很可能是一个自动关卡,仅需一次跳跃越过尖刺。

在第五个测试用例中,通关次数减少了,这也是不可能的。

没有人愿意尝试第六个测试用例;波利卡普的妈妈为了让他心情好些而亲自尝试,然而她未能通关。

输入解题思路,AI测评打分。不知道怎么写?

首页