結果

問題 No.482 あなたの名は
ユーザー mlihua09
提出日時 2020-09-04 14:10:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 106,696 KB
最終ジャッジ日時 2024-11-25 09:37:24
合計ジャッジ時間 4,255 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #


N, K = map(int, input().split())

D = list(map(lambda x: int(x) - 1, input().split()))

I = [0] * N

ans = 0
for i in range(N):
    I[D[i]] = i
    
for i in range(N):
    
    if D[i] != i:
        D[I[i]] = D[i]
        I[D[i]] = I[i]
        ans += 1
if ans <= K and (K - ans) % 2 == 0:
    print('YES')
else:
    print('NO')
0