結果

問題 No.482 あなたの名は
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2017-02-10 23:18:24
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 71,444 KB
実行使用メモリ 66,852 KB
最終ジャッジ日時 2023-08-28 08:52:31
合計ジャッジ時間 16,384 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,784 KB
testcase_01 AC 123 ms
56,196 KB
testcase_02 AC 125 ms
56,180 KB
testcase_03 AC 123 ms
55,816 KB
testcase_04 AC 123 ms
56,216 KB
testcase_05 AC 122 ms
55,892 KB
testcase_06 AC 122 ms
55,964 KB
testcase_07 AC 183 ms
56,496 KB
testcase_08 WA -
testcase_09 AC 141 ms
53,924 KB
testcase_10 AC 179 ms
56,000 KB
testcase_11 AC 184 ms
56,064 KB
testcase_12 WA -
testcase_13 AC 181 ms
56,408 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 663 ms
64,932 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 701 ms
65,056 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 683 ms
64,952 KB
testcase_24 AC 690 ms
64,896 KB
testcase_25 AC 716 ms
64,756 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 687 ms
65,236 KB
testcase_29 AC 711 ms
64,836 KB
testcase_30 AC 122 ms
55,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        int [] D = new int [N+1];
        for(int i=1; i<=N; i++){
            D[i] = sc.nextInt();
        }
        int c=0;
        for(int i=1; i<=N; i++){
            if(i!=D[i]){
                int tmp = D[i];
                D[i] = D[tmp];
                D[tmp] = tmp;
                c++;
            }
        }
        boolean b = true;
        if(c>K)b = false;
        if((K-c)%2==1)b=false;
        if(b){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}
0