結果
問題 |
No.1687 What the Heck?
|
ユーザー |
|
提出日時 | 2021-09-25 02:18:26 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 365 bytes |
コンパイル時間 | 144 ms |
コンパイル使用メモリ | 82,396 KB |
実行使用メモリ | 105,152 KB |
最終ジャッジ日時 | 2024-07-05 11:55:13 |
合計ジャッジ時間 | 2,153 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 6 WA * 12 |
ソースコード
n = int(input()) p = list(map(int,input().split())) use = [True] * (n + 2) use[0] = False use[n + 1] = False ans = 0 usemin = 1 for i in range(n - 1, -1, -1): if use[p[i] + 1]: use[p[i] + 1] = False ans += i + 1 else: use[usemin] = False usemin += 1 if usemin < p[i]: ans -= i + 1 print(ans)