結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:53:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 619 bytes |
| コンパイル時間 | 383 ms |
| コンパイル使用メモリ | 81,912 KB |
| 実行使用メモリ | 109,860 KB |
| 最終ジャッジ日時 | 2025-06-12 16:54:05 |
| 合計ジャッジ時間 | 2,849 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 17 |
ソースコード
import sys
from collections import deque
def main():
N = int(sys.stdin.readline())
P = list(map(int, sys.stdin.readline().split()))
sorted_rounds = sorted(range(1, N+1), key=lambda x: -x)
available_S = deque(range(1, N+1))
total = 0
for i in sorted_rounds:
p_i = P[i-1]
if available_S and available_S[-1] > p_i:
total += i
available_S.pop()
else:
if available_S:
s = available_S.popleft()
if s < p_i:
total -= i
print(total)
if __name__ == "__main__":
main()
gew1fw