第 474 场 AtCoder Beginner Contest
B
离场顺序
Exit Order
AtCoder
⌀ 0
原题
← AD →

离场顺序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$ 人分成一组。
  • 各组按照顺序离场,从座位编号最小的那组开始。同一组内的顾客可以按任意顺序离场。
AI (CI翻译)

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)$ 的一个排列。
  • 所有输入值均为整数。
AI (CI翻译)

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_N
AI (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翻译)

样例

Input #1
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
Output #1
Yes
The $25$ customers were divided into three groups, with seat numbers $1$ to $10$, $11$ to $20$, and $21$ to $25$. First, the $10$ customers in the first group, with seat numbers $1$ to $10$, left. Next, the $10$ customers in the second group, with seat numbers $11$ to $20$, left. Finally, the $5$ customers in the third group, with seat numbers $21$ to $25$, left. Thus, the $25$ customers left according to the rule.
Input #2
11
11 10 7 2 1 5 6 4 8 9 3
Output #2
No
题目信息
题号
abc474_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。