結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2018-09-23 15:51:34 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 728 bytes |
コンパイル時間 | 2,091 ms |
コンパイル使用メモリ | 77,088 KB |
実行使用メモリ | 66,432 KB |
最終ジャッジ日時 | 2024-09-14 01:58:05 |
合計ジャッジ時間 | 14,632 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 RE * 6 |
ソースコード
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.nextInt(); 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"); } } } }