結果
| 問題 |
No.1675 Strange Minimum Query
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-11 10:59:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 857 bytes |
| コンパイル時間 | 291 ms |
| コンパイル使用メモリ | 82,208 KB |
| 実行使用メモリ | 161,100 KB |
| 最終ジャッジ日時 | 2024-06-22 18:31:24 |
| 合計ジャッジ時間 | 35,802 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 1 WA * 24 RE * 9 |
ソースコード
from collections import defaultdict
import heapq
n,q = map(int,input().split())
lr = [[int(i)-1 for i in input().split()] for j in range(q)]
lr.sort(key=lambda x:x[0])
li = [10**9]*n
rm = defaultdict(int)
idx = 0
lrcnt = 0
hp = []
heapq.heapify(hp)
rmhp = []
heapq.heapify(rmhp)
while idx < n:
while lrcnt < q and lr[lrcnt][0] <= idx:
heapq.heappush(hp, -lr[lrcnt][2])
heapq.heappush(rmhp, [lr[lrcnt][1],-lr[lrcnt][2]])
lrcnt += 1
while 1:
if len(rmhp) == 0:
break
pos,val = heapq.heappop(rmhp)
if pos <= idx:
rm[val] += 1
else:
break
while 1:
val = heapq.heappop(hp)
if rm[val] > 0:
rm[val] -= 1
else:
li[idx] = -val+1
heapq.heappush(hp, val)
break
idx += 1
print(*li)