

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
長さ の数列 があります。また、整数 が与えられます。
あなたは次の操作を 回以上何度でも行えます。
- を満たす整数 を選び、 と の値を入れ替える。
を昇順に並べ替えることが出来るかどうかを判定してください。
制約
- 入力はすべて整数
入力
入力は以下の形式で標準入力から与えられる。
出力
を昇順に並び替えることが出来るならば Yes
と、出来ないならば No
と出力せよ。
入力例 1Copy
5 2 3 4 1 3 4
出力例 1Copy
Yes
次のように操作をすることで を昇順に並び替えることが出来ます。
- とし、 と の値を入れ替える。数列は となる。
- とし、 と の値を入れ替える。数列は となる。
入力例 2Copy
5 3 3 4 1 3 4
出力例 2Copy
No
入力例 3Copy
7 5 1 2 3 4 5 5 10
出力例 3Copy
Yes
操作を行う必要が無い場合もあります。
Score : points
Problem Statement
We have a sequence of length : . Additionally, you are given an integer .
You can perform the following operation zero or more times.
- Choose an integer such that , then swap the values of and .
Determine whether it is possible to sort in ascending order.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to sort in ascending order, print Yes
; otherwise, print No
.
Sample Input 1Copy
5 2 3 4 1 3 4
Sample Output 1Copy
Yes
The following sequence of operations sorts in ascending order.
- Choose to swap the values of and . is now .
- Choose to swap the values of and . is now .
Sample Input 2Copy
5 3 3 4 1 3 4
Sample Output 2Copy
No
Sample Input 3Copy
7 5 1 2 3 4 5 5 10
Sample Output 3Copy
Yes
No operations may be needed.