You are given a natural number
Constraints
Subtask 1 [40%]
Subtask 2 [60%]
Input Specification
The first line will contain two space-separated integers,
The next line will contain
Output Specification
Output YES
if it may be sorted and NO
otherwise.
Sample Input 1
5 1
1 4 3 2 5
Sample Output 1
YES
Explanation for Sample 1
Swap 1 4 2 3 5
.
Swap 1 2 4 3 5
.
Swap 1 2 3 4 5
, which is sorted.
Sample Input 2
5 2
5 4 3 2 1
Sample Output 2
YES
Explanation for Sample 2
Swap 5 2 3 4 1
.
Swap 3 2 5 4 1
.
Swap 3 2 1 4 5
.
Swap 1 2 3 4 5
, which is sorted.
Sample Input 3
5 3
5 4 3 2 1
Sample Output 3
NO
Comments