結果

問題 No.1675 Strange Minimum Query
ユーザー stngstng
提出日時 2021-09-11 10:59:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 857 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 157,820 KB
最終ジャッジ日時 2023-09-04 21:02:17
合計ジャッジ時間 39,161 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,448 KB
testcase_01 WA -
testcase_02 AC 94 ms
71,816 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 WA -
testcase_13 AC 742 ms
128,792 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 RE -
testcase_17 WA -
testcase_18 WA -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 RE -
testcase_27 WA -
testcase_28 WA -
testcase_29 RE -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0