結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-24 23:09:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 394 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 82,148 KB |
| 実行使用メモリ | 136,088 KB |
| 最終ジャッジ日時 | 2024-07-05 11:27:59 |
| 合計ジャッジ時間 | 2,365 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 WA * 4 |
ソースコード
N = int(input())
P = list(map(int, input().split()))
total = 0
used = set()
for i in range(N-1, -1, -1):
p = P[i]
if p != N and p+1 not in used:
total += i+1
used.add(p+1)
elif p not in used:
used.add(p)
else:
total -= i+1
for j in range(1, N):
if j not in used:
used.add(j)
break
print(total)