#ABC478C. 排序子数组 / Sort Subarray
排序子数组 / Sort Subarray
Problem Statement
You are given a length- integer sequence .
You will perform the following operation on exactly once.
- Choose an integer between and , inclusive. Sort in ascending order. More formally, let be arranged in increasing order, and simultaneously replace with for .
Determine whether it is possible that, after this operation, is in ascending order, that is, holds for all .
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
If can be sorted in ascending order by performing the operation once, output Yes; otherwise, output No.
9 6
1 4 1 4 2 1 3 5 6
Yes
For example, if you choose as , then is replaced with . After the operation, is , which satisfies the condition.
Thus, output Yes.
3 1
3 2 1
No
, so does not change regardless of which the operation is performed on. Thus, output No.
30 25
1 2 2 22 14 10 14 10 18 5 15 8 17 22 10 17 11 25 13 16 9 19 26 7 11 12 23 3 30 30
Yes
- Source: AtCoder ABC 478 C
相关
在下列比赛中: