AT_abc474_b.Exit Order
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
- 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.
Here, the last group may have fewer than 10 customers.
The customer who left i-th was the one sitting in seat Pi.
Determine whether the N customers left according to the rule.
有一家电影院,共有 N 个座位,编号为 1 至 N,每个座位上均坐有一名顾客。
为缓解拥挤,该影院要求顾客按如下规则离场:
- 将顾客按其所坐座位编号从小到大的顺序,每 10 人分为一组;
- 各组按顺序离场,即从座位编号最小的顾客所在的组开始;同一组内的顾客可按任意顺序离场。
注意:最后一组可能少于 10 名顾客。
第 i 个离场的顾客原本坐在座位 Pi 上。
请判断这 N 名顾客是否符合上述离场规则。
输入格式
The input is given from Standard Input in the following format:
N
P1 P2 … PN
输入从标准输入中按以下格式给出:
N
P1 P2 … PN
输出格式
Output Yes if the N customers left according to the rule, and No otherwise, in one line.
如果 N 位顾客按照规则离开,则输出 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 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.
Constraints
- 10≤N≤100
- (P1,P2,…,PN) is a permutation of (1,2,…,N).
- All input values are integers.
样例 1 解释:
这 25 名顾客被分为三组,座位号分别为 1 至 10、11 至 20 和 21 至 25。
首先,第一组(座位号 1 至 10)的 10 名顾客离开。
接着,第二组(座位号 11 至 20)的 10 名顾客离开。
最后,第三组(座位号 21 至 25)的 5 名顾客离开。
因此,这 25 名顾客按照规则全部离开了。
约束条件
- 10≤N≤100
- (P1,P2,…,PN) 是 (1,2,…,N) 的一个排列。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?