結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:06:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 379 bytes |
| コンパイル時間 | 419 ms |
| コンパイル使用メモリ | 82,428 KB |
| 実行使用メモリ | 111,072 KB |
| 最終ジャッジ日時 | 2025-06-12 14:06:55 |
| 合計ジャッジ時間 | 2,749 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 17 |
ソースコード
n = int(input())
p = list(map(int, input().split()))
rounds = sorted([(p[i], i + 1) for i in range(n)], key=lambda x: -x[1])
a = sorted(range(1, n + 1), reverse=True)
pointer = 0
ans = 0
for pi, i in rounds:
if pointer < len(a) and a[pointer] > pi:
ans += i
pointer += 1
else:
if a and a[-1] < pi:
ans -= i
a.pop()
print(ans)
gew1fw