結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
YamaKasa
|
| 提出日時 | 2018-09-23 15:53:51 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 821 ms / 2,000 ms |
| コード長 | 730 bytes |
| コンパイル時間 | 2,250 ms |
| コンパイル使用メモリ | 77,664 KB |
| 実行使用メモリ | 69,520 KB |
| 最終ジャッジ日時 | 2024-09-14 02:12:01 |
| 合計ジャッジ時間 | 17,857 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
long K = scan.nextLong();
int[]D1 = new int[N + 1];
int[]D2 = new int[N + 1];
for(int i = 0; i < N; i++) {
int t = scan.nextInt();
D1[i + 1] = t;
D2[t] = i + 1;
}
scan.close();
long cnt = 0;
for(int i = 1; i <= N; i++) {
if(D1[i] != i) {
int t1 = D1[i];
int t2 = D2[i];
D1[i] = i;
D2[i] = i;
D1[t2] = t1;
D2[t1] = t2;
cnt++;
}
}
if(cnt > K) {
System.out.println("NO");
}else {
long t = K - cnt;
if(t % 2 == 0) {
System.out.println("YES");
}else {
System.out.println("NO");
}
}
}
}
YamaKasa