結果

問題 No.693 square1001 and Permutation 2
ユーザー 👑 KazunKazun
提出日時 2020-10-03 03:51:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 239 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,148 KB
実行使用メモリ 71,560 KB
最終ジャッジ日時 2023-09-25 04:40:14
合計ジャッジ時間 2,175 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,484 KB
testcase_01 AC 76 ms
71,228 KB
testcase_02 AC 75 ms
71,560 KB
testcase_03 AC 77 ms
71,484 KB
testcase_04 AC 77 ms
71,360 KB
testcase_05 AC 75 ms
71,520 KB
testcase_06 AC 75 ms
71,444 KB
testcase_07 AC 72 ms
71,408 KB
testcase_08 AC 72 ms
71,260 KB
testcase_09 AC 74 ms
71,368 KB
testcase_10 AC 74 ms
71,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))

X=set(range(1,N+1))
Y=[]
for a in A:
    if a in X:
        X.remove(a)
    else:
        Y.append(a)

X=sorted(list(X))
Y.sort()

K=0
for i in range(len(X)):
    K+=abs(X[i]-Y[i])

print(K)
0