最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網 會員登陸 & 注冊

CF A. Beautiful Sequence

2023-06-08 20:34 作者:您是打尖兒還是住店呢  | 我要投稿

A sequence of m integers a1,a2,…,am is good, if and only if there exists at least one i

?(1≤i≤m) such that ai=i. For example, [3,2,3] is a good sequence, since a2=2

, a3=3, while [3,1,1] is not a good sequence, since there is no i

?such that ai=i?

A sequence a is beautiful, if and only if there exists at least one subsequence of a

?satisfying that this subsequence is good. For example, [4,3,2] is a beautiful sequence, since its subsequence [4,2] is good, while [5,3,4] is not a beautiful sequence.

A sequence b is a subsequence of a sequence a if b can be obtained from a

?by the deletion of several (possibly, zero or all) elements.

Now you are given a sequence, check whether it is beautiful or not.

Input

Each test contains multiple test cases. The first line contains a single integer t

?(1≤t≤500) — the number of test cases. Their description follows.

The first line of each test case contains an integer n

?(1≤n≤100) — the length of the given sequence.

The second line of each test case contains n

?integers a1,a2,…,an (1≤ai≤109), representing the sequence.

Output

For each test case, output "YES" or "NO"(without quotes) in one line, representing whether the given sequence is beautiful.

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.

Example

7

3

3 2 1

4

2 4 3 5

5

2 3 5 5 6

2

3 1

5

2 4 5 2 3

4

5 6 7 8

6

6 5 4 3 2 1

outputCopy

YES

YES

NO

YES

YES

NO

YES

Note

In the first test case, the good subsequence is b=[3,2], where b2=2

.In the second test case, the good subsequence is b=[2,4,3], where b3=3

.In the fourth test case, the good subsequence is b=[1], where b1=1

.In the fifth test case, the good subsequence is b=[2,2], where b2=2

只要存在元素的值小于對應的索引值+1就說明是beautiful的。

下面是代碼:


CF A. Beautiful Sequence的評論 (共 條)

分享到微博請遵守國家法律
邮箱| 拉孜县| 大冶市| 花垣县| 明光市| 西林县| 普定县| 巴南区| 株洲市| 云霄县| 云和县| 金坛市| 兴文县| 织金县| 惠东县| 青岛市| 抚松县| 元朗区| 甘洛县| 台前县| 东乌珠穆沁旗| 宝鸡市| 甘洛县| 浑源县| 固原市| 武宣县| 通许县| 洪洞县| 玉门市| 彭泽县| 托克逊县| 保靖县| 荔波县| 宁波市| 定西市| 余江县| 禄丰县| 绵竹市| 大名县| 寻乌县| 缙云县|