結果

問題 No.482 あなたの名は
ユーザー YamaKasa
提出日時 2018-09-23 15:03:31
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 708 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 75,004 KB
実行使用メモリ 69,308 KB
最終ジャッジ日時 2024-09-14 00:23:18
合計ジャッジ時間 30,406 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 RE * 6 TLE * 10
権限があれば一括ダウンロードができます

ソースコード

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