結果

問題 No.1687 What the Heck?
ユーザー brthyyjp
提出日時 2021-09-24 21:53:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 246 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 107,776 KB
最終ジャッジ日時 2024-07-05 10:28:12
合計ジャッジ時間 2,220 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 2 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
P = list(map(int, input().split()))
Q = list(range(1, n+1))
ans = 0
for i in reversed(range(n)):
    p = P[i]
    q = Q[i]
    if q > p:
        ans += i+1
    elif q < p:
        ans -= i+1
    else:
        continue
print(ans)
0