結果

問題 No.482 あなたの名は
ユーザー YamaKasa
提出日時 2018-09-23 14:40:02
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 74,460 KB
実行使用メモリ 54,560 KB
最終ジャッジ日時 2024-09-13 23:46:24
合計ジャッジ時間 14,817 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 10 RE * 6
権限があれば一括ダウンロードができます

ソースコード

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(i + 1 != D[i]) {
				cnt++;
			}
		}
		if(cnt / 2 > K) {
			System.out.println("NO");
		}else {
			long t = K - cnt / 2;
			if(t % 2 == 0) {
				System.out.println("YES");
			}else {
				System.out.println("NO");
			}
		}
	}
}
0