結果
| 問題 | 
                            No.1675 Strange Minimum Query
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-09-11 11:19:41 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 971 bytes | 
| コンパイル時間 | 158 ms | 
| コンパイル使用メモリ | 81,976 KB | 
| 実行使用メモリ | 186,352 KB | 
| 最終ジャッジ日時 | 2024-06-22 18:56:26 | 
| 合計ジャッジ時間 | 44,546 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 24 WA * 2 TLE * 8 | 
ソースコード
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:
            heapq.heappush(rmhp, [pos,val])
            break
    while 1:
        if len(hp) == 0:
            li[idx] = 10**9
            break
        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)