310453: CF1836A. Destroyer

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Destroyertime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

John is a lead programmer on a destroyer belonging to the space navy of the Confederacy of Independent Operating Systems. One of his tasks is checking if the electronic brains of robots were damaged during battles.

A standard test is to order the robots to form one or several lines, in each line the robots should stand one after another. After that, each robot reports the number of robots standing in front of it in its line.

An example of robots' arrangement (the front of the lines is on the left). The robots report the numbers above.

The $i$-th robot reported number $l_i$. Unfortunately, John does not know which line each robot stands in, and can't check the reported numbers. Please determine if it is possible to form the lines in such a way that all reported numbers are correct, or not.

Input

The first line contains a single integer $t$ ($1 \leq t \leq 100$), denoting the number of test cases.

The first line in each test case contains a single integer $n$ ($1 \le n \le 100$) — the number of robots.

The second line in each test case contains $n$ integers $l_1, l_2, \ldots, l_n$ ($0 \leq l_i < 100$), $l_i$ is equal to the number of robots in front of the $i$-th robot in its line.

The sum of $n$ over all test cases won't exceed $200$.

Output

For each test case, output "YES", if there exists a robot arrangement consistent with robots' reports. Otherwise, output "NO".

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

ExampleInput
5
6
0 1 2 0 1 0
9
0 0 0 0 1 1 1 2 2
3
0 0 2
1
99
5
0 1 2 3 4
Output
YES
YES
NO
NO
YES
Note

Example arrangement consistent with robot statements from the first example test case:

Example arrangement consistent with robot statements from the second example is shown in the statement.

In the third test case, the third robot claims that there are two machines in front of it. In such a case, the robot directly in front of it would have one machine in front. No robot claims that, so there is no valid arrangement.

Input

题意翻译

### 描述 约翰是独立操作系统联邦空间海军的一艘驱逐舰上的首席程序员。他的任务之一是检查机器人的电子大脑是否在战斗中受损。 一个标准的测试是命令机器人排成一行或多行,每行机器人应该一个接一个地站立。然后,每个机器人报告它所在行前面的机器人数量。 机器人排列的一个例子(行的前面在左边)。机器人报告的数字如上所示。第$i$个机器人报告了数字$li$。不幸的是,约翰不知道每个机器人所在的行,并且无法检查报告的数字。请确定是否可能以这样的方式排列机器人,使得所有报告的数字都是正确的。 ### 输入 第一行包含一个整数$t$($1≤t≤100$),表示测试用例的数量。 每个测试用例的第一行包含一个整数$n$($1≤n≤100$),表示机器人的数量。 每个测试用例的第二行包含$n$个整数$l_1,l_2,…,l_n$($0≤l_i<100$),$l_i$表示第$i$个机器人所在行前面的机器人数量。 所有测试用例中$n$的总和不超过$200$。 ### 输出 对于每个测试用例,如果存在与机器人报告一致的机器人排列,则输出`YES`。否则,输出`NO`。 你可以以任何大小写形式输出答案。例如,字符串`yEs`、`yes`、`Yes`和`YES`都将被识别为肯定的回答。 ### 提示 在第三个测试用例中,第三个机器人声称它前面有两个机器人。在这种情况下,直接在它前面的机器人应该有一个机器人在前面。没有机器人声称有这种情况,因此没有有效的排列。

Output

题目大意:
约翰是独立操作系统联盟太空海军一艘驱逐舰上的首席程序员。他的任务之一是检查战斗中机器人的电子大脑是否受损。一个标准测试是命令机器人排成一列或几列,每列中的机器人一个接一个地站立。之后,每个机器人报告它所在的列中站在它前面的机器人数。

输入数据格式:
第一行包含一个整数 t(1 ≤ t ≤ 100),表示测试用例的数量。
每个测试用例的第一行包含一个整数 n(1 ≤ n ≤ 100)——机器人的数量。
每个测试用例的第二行包含 n 个整数 l_1, l_2, …, l_n(0 ≤ l_i < 100),l_i 等于第 i 个机器人所在列中站在它前面的机器人数。
所有测试用例的 n 之和不会超过 200。

输出数据格式:
对于每个测试用例,如果存在与机器人报告一致的排列方式,则输出 "YES",否则输出 "NO"。
输出答案时大小写不敏感,例如 "yEs"、"yes"、"Yes" 和 "YES" 都会被认为是肯定响应。

公式(使用 LaTeX 格式):
无具体公式,只有问题描述和输入输出格式。题目大意: 约翰是独立操作系统联盟太空海军一艘驱逐舰上的首席程序员。他的任务之一是检查战斗中机器人的电子大脑是否受损。一个标准测试是命令机器人排成一列或几列,每列中的机器人一个接一个地站立。之后,每个机器人报告它所在的列中站在它前面的机器人数。 输入数据格式: 第一行包含一个整数 t(1 ≤ t ≤ 100),表示测试用例的数量。 每个测试用例的第一行包含一个整数 n(1 ≤ n ≤ 100)——机器人的数量。 每个测试用例的第二行包含 n 个整数 l_1, l_2, …, l_n(0 ≤ l_i < 100),l_i 等于第 i 个机器人所在列中站在它前面的机器人数。 所有测试用例的 n 之和不会超过 200。 输出数据格式: 对于每个测试用例,如果存在与机器人报告一致的排列方式,则输出 "YES",否则输出 "NO"。 输出答案时大小写不敏感,例如 "yEs"、"yes"、"Yes" 和 "YES" 都会被认为是肯定响应。 公式(使用 LaTeX 格式): 无具体公式,只有问题描述和输入输出格式。

加入题单

上一题 下一题 算法标签: