結果

問題 No.482 あなたの名は
ユーザー shinwisteriashinwisteria
提出日時 2017-03-30 18:23:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 721 ms / 2,000 ms
コード長 667 bytes
コンパイル時間 3,156 ms
コンパイル使用メモリ 72,336 KB
実行使用メモリ 66,988 KB
最終ジャッジ日時 2023-09-21 08:46:20
合計ジャッジ時間 17,621 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
56,104 KB
testcase_01 AC 125 ms
57,220 KB
testcase_02 AC 126 ms
55,880 KB
testcase_03 AC 125 ms
55,828 KB
testcase_04 AC 124 ms
55,964 KB
testcase_05 AC 125 ms
55,980 KB
testcase_06 AC 124 ms
55,736 KB
testcase_07 AC 184 ms
56,552 KB
testcase_08 AC 178 ms
58,324 KB
testcase_09 AC 140 ms
57,832 KB
testcase_10 AC 179 ms
56,360 KB
testcase_11 AC 185 ms
56,428 KB
testcase_12 AC 183 ms
56,504 KB
testcase_13 AC 167 ms
56,028 KB
testcase_14 AC 166 ms
56,356 KB
testcase_15 AC 672 ms
65,220 KB
testcase_16 AC 672 ms
64,768 KB
testcase_17 AC 721 ms
64,932 KB
testcase_18 AC 674 ms
64,776 KB
testcase_19 AC 671 ms
65,164 KB
testcase_20 AC 685 ms
64,960 KB
testcase_21 AC 693 ms
65,012 KB
testcase_22 AC 675 ms
65,220 KB
testcase_23 AC 659 ms
64,736 KB
testcase_24 AC 676 ms
64,768 KB
testcase_25 AC 700 ms
64,736 KB
testcase_26 AC 688 ms
64,820 KB
testcase_27 AC 711 ms
65,128 KB
testcase_28 AC 670 ms
65,240 KB
testcase_29 AC 702 ms
66,988 KB
testcase_30 AC 123 ms
56,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class YourName {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		long K = s.nextLong();
		int[] D = new int[N];
		for(int i = 0;i < N;i++){
			D[i] = s.nextInt();
			if(i+1 == D[i]){
				D[i] = 0;
			}
		}
		s.close();
		for(int i = 0;i < N;i++){
			if(D[i] != 0){
				while(D[i] != i+1){
					//System.out.println("D[" + i + "] = " + D[i] + "  " + K);
					int k = D[D[i]-1];
					D[D[i]-1] = 0;
					D[i] = k;
					K--;
				}
				if(K < 0){
					break;
				}
			}
		}
		if(K >= 0 &&K % 2 == 0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

	}

}
0