离场顺序 / Exit Order
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Problem Statement
There is a movie theater with seats numbered through , 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 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 customers.
The customer who left -th was the one sitting in seat . Determine whether the customers left according to the rule.
Constraints
- is a permutation of .
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Output Yes if the customers left according to the rule, and No otherwise, in one line.
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
The customers were divided into three groups, with seat numbers to , to , and to . First, the customers in the first group, with seat numbers to , left. Next, the customers in the second group, with seat numbers to , left. Finally, the customers in the third group, with seat numbers to , left. Thus, the customers left according to the rule.
11
11 10 7 2 1 5 6 4 8 9 3
No
- Source: AtCoder ABC 474 B