結果

問題 No.482 あなたの名は
ユーザー htensaihtensai
提出日時 2020-05-07 15:45:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 727 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 1,892 ms
コンパイル使用メモリ 71,984 KB
実行使用メモリ 65,000 KB
最終ジャッジ日時 2023-09-16 07:54:31
合計ジャッジ時間 16,680 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,772 KB
testcase_01 AC 120 ms
55,856 KB
testcase_02 AC 121 ms
55,600 KB
testcase_03 AC 122 ms
56,212 KB
testcase_04 AC 121 ms
55,704 KB
testcase_05 AC 123 ms
55,680 KB
testcase_06 AC 125 ms
55,644 KB
testcase_07 AC 183 ms
56,240 KB
testcase_08 AC 178 ms
56,100 KB
testcase_09 AC 136 ms
53,976 KB
testcase_10 AC 158 ms
55,852 KB
testcase_11 AC 179 ms
55,848 KB
testcase_12 AC 182 ms
55,924 KB
testcase_13 AC 179 ms
56,056 KB
testcase_14 AC 172 ms
55,980 KB
testcase_15 AC 682 ms
64,860 KB
testcase_16 AC 668 ms
64,788 KB
testcase_17 AC 675 ms
64,452 KB
testcase_18 AC 657 ms
64,412 KB
testcase_19 AC 670 ms
64,600 KB
testcase_20 AC 727 ms
64,884 KB
testcase_21 AC 701 ms
65,000 KB
testcase_22 AC 669 ms
64,824 KB
testcase_23 AC 681 ms
64,656 KB
testcase_24 AC 706 ms
64,608 KB
testcase_25 AC 667 ms
64,752 KB
testcase_26 AC 688 ms
64,356 KB
testcase_27 AC 671 ms
64,696 KB
testcase_28 AC 664 ms
64,936 KB
testcase_29 AC 711 ms
64,308 KB
testcase_30 AC 121 ms
55,808 KB
権限があれば一括ダウンロードができます

ソースコード

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];
		for (int i = 1; i <= n; i++) {
		    arr[i] = sc.nextInt();
		}
		for (int i = 1; i <= n; i++) {
		    while (arr[i] != i) {
		        int idx = arr[i];
		        arr[i] = arr[idx];
		        arr[idx] = idx;
		        k--;
		    }
		}
		if (k >= 0 && k % 2 == 0) {
		    System.out.println("YES");
		} else {
		    System.out.println("NO");
		}
	}
}
0