結果

問題 No.482 あなたの名は
ユーザー htensaihtensai
提出日時 2020-02-14 11:59:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 2,624 ms
コンパイル使用メモリ 75,620 KB
実行使用メモリ 78,708 KB
最終ジャッジ日時 2024-04-16 00:13:41
合計ジャッジ時間 23,397 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,792 KB
testcase_01 AC 129 ms
41,484 KB
testcase_02 AC 128 ms
41,548 KB
testcase_03 AC 133 ms
41,656 KB
testcase_04 AC 132 ms
41,632 KB
testcase_05 WA -
testcase_06 AC 130 ms
41,620 KB
testcase_07 AC 185 ms
42,488 KB
testcase_08 AC 183 ms
42,564 KB
testcase_09 AC 144 ms
41,932 KB
testcase_10 AC 184 ms
42,536 KB
testcase_11 AC 191 ms
42,528 KB
testcase_12 AC 193 ms
42,704 KB
testcase_13 AC 179 ms
42,280 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1,114 ms
77,804 KB
testcase_17 AC 1,126 ms
78,120 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1,070 ms
78,400 KB
testcase_25 AC 1,062 ms
78,228 KB
testcase_26 WA -
testcase_27 AC 1,096 ms
77,368 KB
testcase_28 AC 1,061 ms
78,188 KB
testcase_29 AC 953 ms
77,500 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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");
		}
  }
}
0