結果

問題 No.482 あなたの名は
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2017-02-10 23:27:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 700 bytes
コンパイル時間 1,893 ms
コンパイル使用メモリ 71,272 KB
実行使用メモリ 66,900 KB
最終ジャッジ日時 2023-08-28 09:05:21
合計ジャッジ時間 16,327 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
56,232 KB
testcase_01 AC 121 ms
57,860 KB
testcase_02 AC 122 ms
55,544 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 120 ms
56,048 KB
testcase_06 WA -
testcase_07 AC 167 ms
56,200 KB
testcase_08 WA -
testcase_09 AC 139 ms
55,876 KB
testcase_10 AC 174 ms
56,012 KB
testcase_11 AC 178 ms
56,264 KB
testcase_12 AC 184 ms
56,316 KB
testcase_13 AC 164 ms
56,168 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 689 ms
65,216 KB
testcase_18 AC 713 ms
64,600 KB
testcase_19 WA -
testcase_20 AC 720 ms
64,704 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 677 ms
64,968 KB
testcase_25 AC 698 ms
64,708 KB
testcase_26 AC 708 ms
64,568 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 712 ms
64,784 KB
testcase_30 AC 123 ms
55,752 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||K-c==1)b = false;
        if(b){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}
0