当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7034:Array

题目描述
Koishi gives you an array $B$ of length $n$ satisfying $1 \leq B_1 \leq B_2 \leq \cdots \leq B_n \leq n+1$.

Let $S(T)$ denote the set of numbers that appear in array $T$. She asks you whether an array $A$ of length $n$ exists so that for any $l, r(1 \leq l \leq r \leq n)$, $S(A[l,r])=S(A[1,n])$ holds if and only if $r \ge B_l$.

$A[l,r]$ represents the sub-array of $A$ formed by $A_l, A_{l+1}, \cdots, A_{r}$.

Notice: If there exists a $i(1\leq i\leq n)$, that $B_i<i$ holds, the required $A$ must not exist.
输入解释
The first line contains an integer $T(1 \leq T \leq 3 \times 10^4)$ - the number of test cases. Then $T$ test cases follow.

The first line of each test case contains an integer $n(1\leq n \leq 2 \times 10^5)$ - the length of array $B$ (and $A$).

The next line contains $n$ integers $B_1, B_2, \cdots, B_n(1\leq B_1\leq B_2......\leq B_n\leq n+1)$ - the array that Koishi gives you.

It is guaranteed that $\sum n \leq 4.5 \times 10^6$.
输出解释
For each test case, output "YES" if the array $A$ exists, or "NO" otherwise.
输入样例
3
4
3 3 5 5
7
4 6 6 7 8 8 8
5
2 3 4 4 6
输出样例
YES
YES
NO

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7034

最后修改于 2021-10-23T19:11:08+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000/5000MS(Java/Others) 524288/524288K(Java/Others)