結果

問題 No.482 あなたの名は
ユーザー YamaKasaYamaKasa
提出日時 2018-09-23 15:03:31
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 708 bytes
コンパイル時間 2,439 ms
コンパイル使用メモリ 71,304 KB
実行使用メモリ 65,324 KB
最終ジャッジ日時 2023-10-12 00:28:12
合計ジャッジ時間 28,646 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,688 KB
testcase_01 AC 126 ms
55,544 KB
testcase_02 AC 124 ms
56,188 KB
testcase_03 AC 125 ms
55,964 KB
testcase_04 AC 125 ms
56,120 KB
testcase_05 AC 125 ms
55,512 KB
testcase_06 AC 126 ms
55,652 KB
testcase_07 AC 190 ms
55,924 KB
testcase_08 AC 180 ms
56,088 KB
testcase_09 AC 142 ms
56,256 KB
testcase_10 AC 182 ms
55,828 KB
testcase_11 AC 187 ms
56,124 KB
testcase_12 AC 189 ms
57,156 KB
testcase_13 AC 174 ms
55,752 KB
testcase_14 AC 154 ms
56,000 KB
testcase_15 TLE -
testcase_16 AC 1,911 ms
64,936 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 AC 1,937 ms
64,760 KB
testcase_23 AC 1,917 ms
65,200 KB
testcase_24 TLE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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[]D = new int[N];
		for(int i = 0; i < N; i++) {
			D[i] = scan.nextInt();
		}
		scan.close();
		long cnt = 0;
		for(int i = 0; i < N; i++) {
			if(D[i] == i + 1) {
				continue;
			}
			for(int j = i + 1; j < N; j++) {
				if(D[j] == i + 1) {
					int v = D[i];
					D[i] = i + 1;
					D[j] = v;
					cnt ++;
					break;
				}
			}

		}

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