結果

問題 No.482 あなたの名は
ユーザー shinwisteria
提出日時 2017-03-20 20:51:45
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 666 bytes
コンパイル時間 4,162 ms
コンパイル使用メモリ 81,536 KB
実行使用メモリ 82,668 KB
最終ジャッジ日時 2024-07-05 04:32:30
合計ジャッジ時間 10,805 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;

public class YourName {
	static ArrayList<Integer> list = new ArrayList<>();
	static long K;
	static int N;

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		N = s.nextInt();
		K = s.nextLong();
		for(int i = 0;i<N;i++){
			list.add(s.nextInt());
		}
		s.close();
		for(int i = 0;i<N;i++){
			swtch(i);
		}
		if(K > 0&&K%2 == 0){
			K = 0;
		}
		if(K == 0)
			System.out.println("YES");
		else
			System.out.println("NO");
	}
	
	static void swtch(int i){
		if(i+1 != list.get(i)){
			int t = list.indexOf(i+1);
			list.set(t, list.get(i));
			list.set(i, i+1);
			K--;
		}
	}

}
0