結果

問題 No.482 あなたの名は
ユーザー GrayCoderGrayCoder
提出日時 2018-06-24 20:51:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 10,748 KB
実行使用メモリ 29,968 KB
最終ジャッジ日時 2023-09-13 13:46:44
合計ジャッジ時間 3,293 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,780 KB
testcase_01 AC 16 ms
7,712 KB
testcase_02 AC 15 ms
7,716 KB
testcase_03 AC 15 ms
7,720 KB
testcase_04 AC 15 ms
7,716 KB
testcase_05 AC 15 ms
7,756 KB
testcase_06 AC 15 ms
7,912 KB
testcase_07 AC 15 ms
7,780 KB
testcase_08 AC 16 ms
7,832 KB
testcase_09 AC 15 ms
7,776 KB
testcase_10 AC 16 ms
7,848 KB
testcase_11 AC 16 ms
7,900 KB
testcase_12 AC 15 ms
7,848 KB
testcase_13 AC 15 ms
7,900 KB
testcase_14 AC 15 ms
7,724 KB
testcase_15 AC 101 ms
29,812 KB
testcase_16 AC 102 ms
29,772 KB
testcase_17 AC 101 ms
29,940 KB
testcase_18 AC 98 ms
29,876 KB
testcase_19 AC 99 ms
29,960 KB
testcase_20 AC 101 ms
29,768 KB
testcase_21 AC 102 ms
29,948 KB
testcase_22 AC 100 ms
29,772 KB
testcase_23 AC 99 ms
29,876 KB
testcase_24 AC 103 ms
29,844 KB
testcase_25 AC 103 ms
29,856 KB
testcase_26 AC 99 ms
29,928 KB
testcase_27 AC 100 ms
29,840 KB
testcase_28 AC 100 ms
29,860 KB
testcase_29 AC 96 ms
29,968 KB
testcase_30 AC 15 ms
7,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    N, K = map(int, input().split())
    D = list(map(int, input().split()))

    ope = 0
    d = [0] + D
    i = 1
    while 1:
        if d[i] != i:
            j = d[i]
            d[i], d[j] = d[j], d[i]
            ope += 1
        else:
            i += 1
            if i > N:
                break
        if ope > K:
            write('NO\n')
            return

    if K >= ope and K % 2 == ope % 2:
        write('YES\n')
    else:
        write('NO\n')

main()
0