离场顺序AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)There is a movie theater with $N$ seats numbered $1$ through $N$, and one customer is sitting in each seat.
As a measure against congestion, this theater has customers leave according to the following rule.
有一家电影院,共有 $N$ 个座位,编号为 $1$ 到 $N$,每个座位上都坐着一位顾客。
为避免拥挤,电影院规定顾客按照以下规则离场:AI (CI翻译)
- Divide the customers into groups of
$10$people each, in increasing order of the seat number they are sitting in. - The groups leave in order, starting from the group consisting of customers with the smallest seat numbers. Customers within the same group may leave in any order.
- 按座位编号从小到大的顺序,将顾客每
$10$人分成一组。 - 各组按照顺序离场,从座位编号最小的那组开始。同一组内的顾客可以按任意顺序离场。
Here, the last group may have fewer than $10$ customers.
最后一组的人数可能少于 $10$ 人。AI (CI翻译)
The customer who left $i$-th was the one sitting in seat $P_i$.
Determine whether the $N$ customers left according to the rule.
第 $i$ 个离场的顾客原本坐在座位 $P_i$ 上。请判断这 $N$ 位顾客是否按照上述规则离场。AI (CI翻译)
Constraints
约束条件
AI (CI翻译)$10 \leq N \leq 100$$(P_1,P_2,\dots,P_N)$is a permutation of$(1,2,\dots,N)$.- All input values are integers.
$10 \leq N \leq 100$$(P_1,P_2,\dots,P_N)$是$(1,2,\dots,N)$的一个排列。- 所有输入值均为整数。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入从标准输入按以下格式给出:AI (CI翻译)
N
P_1 P_2 \ldots P_N
N
P_1 P_2 \ldots P_NAI (CI翻译)
Output
输出格式
AI (CI翻译)Output Yes if the $N$ customers left according to the rule, and No otherwise, in one line.
如果这 $N$ 位顾客按照上述规则离场,则输出 Yes;否则输出 No。输出一行。AI (CI翻译)
样例
25
1 6 5 7 8 10 2 4 3 9 15 17 12 11 19 20 18 13 14 16 21 23 24 22 25
Yes
11
11 10 7 2 1 5 6 4 8 9 3
No
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。