AT_abc474_b.Exit Order

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There is a movie theater with NN seats numbered 11 through NN, and one customer is sitting in each seat.
As a measure against congestion, this theater has customers leave according to the following rule.

  • Divide the customers into groups of 1010 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.

Here, the last group may have fewer than 1010 customers.

The customer who left ii-th was the one sitting in seat PiP_i.
Determine whether the NN customers left according to the rule.

有一家电影院,共有 NN 个座位,编号为 11 至 NN,每个座位上均坐有一名顾客。
为缓解拥挤,该影院要求顾客按如下规则离场:

  • 将顾客按其所坐座位编号从小到大的顺序,每 1010 人分为一组;
  • 各组按顺序离场,即从座位编号最小的顾客所在的组开始;同一组内的顾客可按任意顺序离场。

注意:最后一组可能少于 1010 名顾客。

第 ii 个离场的顾客原本坐在座位 PiP_i 上。
请判断这 NN 名顾客是否符合上述离场规则。

输入格式

The input is given from Standard Input in the following format:

NN
P1P_1 P2P_2 …\ldots PNP_N

输入从标准输入中按以下格式给出:

NN
P1P_1 P2P_2 …\ldots PNP_N

输出格式

Output Yes if the NN customers left according to the rule, and No otherwise, in one line.

如果 NN 位顾客按照规则离开,则输出 Yes,否则输出 No,结果占一行。

输入输出样例

  • 输入#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

    输出#1

    Yes
  • 输入#2

    11
    11 10 7 2 1 5 6 4 8 9 3

    输出#2

    No

说明/提示

Sample 1 Explanation:
The 2525 customers were divided into three groups, with seat numbers 11 to 1010, 1111 to 2020, and 2121 to 2525.
First, the 1010 customers in the first group, with seat numbers 11 to 1010, left.
Next, the 1010 customers in the second group, with seat numbers 1111 to 2020, left.
Finally, the 55 customers in the third group, with seat numbers 2121 to 2525, left.
Thus, the 2525 customers left according to the rule.

Constraints

  • 10≤N≤10010 \leq N \leq 100
  • (P1,P2,…,PN)(P_1,P_2,\dots,P_N) is a permutation of (1,2,…,N)(1,2,\dots,N).
  • All input values are integers.

样例 1 解释:
这 2525 名顾客被分为三组,座位号分别为 11 至 1010、1111 至 2020 和 2121 至 2525。
首先,第一组(座位号 11 至 1010)的 1010 名顾客离开。
接着,第二组(座位号 1111 至 2020)的 1010 名顾客离开。
最后,第三组(座位号 2121 至 2525)的 55 名顾客离开。
因此,这 2525 名顾客按照规则全部离开了。

约束条件

  • 10≤N≤10010 \leq N \leq 100
  • (P1,P2,…,PN)(P_1,P_2,\dots,P_N) 是 (1,2,…,N)(1,2,\dots,N) 的一个排列。
  • 所有输入值均为整数。

输入解题思路,AI测评打分。不知道怎么写?

首页