結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2020-02-14 11:59:41 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 668 bytes |
コンパイル時間 | 1,977 ms |
コンパイル使用メモリ | 77,436 KB |
実行使用メモリ | 88,532 KB |
最終ジャッジ日時 | 2024-10-06 07:51:25 |
合計ジャッジ時間 | 20,756 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 11 |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); int[] arr = new int[n + 1]; HashMap<Integer, Integer> map = new HashMap<>(); for (int i = 1; i <= n; i++) { arr[i] = sc.nextInt(); map.put(arr[i], i); } int count = 0; for (int i = 1; i <= n; i++) { int x = map.get(i); if (i == x) { continue; } count++; arr[x] = arr[i]; map.put(x, arr[i]); } if (k >= count && (k - count) % 2 == 0) { System.out.println("YES"); } else { System.out.println("NO"); } } }