結果

問題 No.482 あなたの名は
ユーザー k-mats
提出日時 2017-02-10 22:53:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 470 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 40,320 KB
最終ジャッジ日時 2024-12-28 08:52:27
合計ジャッジ時間 47,101 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 TLE * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]

def sort(d, k):
    cnt = 0
    for i in range(len(d)):
        if d[i] == i + 1:
            continue
        for j in range(i + 1, len(d)):
            if d[j] == i + 1:
                d[i], d[j] = d[j], d[i]
                cnt += 1
                break
        if cnt > k:
            return False

    return (k - cnt) % 2 == 0

if sort(d, k):
    print('YES')
else:
    print('NO')
0