結果

問題 No.1675 Strange Minimum Query
ユーザー stngstng
提出日時 2021-09-11 11:19:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 971 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 183,820 KB
最終ジャッジ日時 2023-09-04 21:28:10
合計ジャッジ時間 53,616 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,128 KB
testcase_01 WA -
testcase_02 AC 92 ms
70,880 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 TLE -
testcase_08 AC 93 ms
71,552 KB
testcase_09 AC 157 ms
78,000 KB
testcase_10 AC 574 ms
102,856 KB
testcase_11 AC 205 ms
83,504 KB
testcase_12 AC 641 ms
106,412 KB
testcase_13 AC 781 ms
127,976 KB
testcase_14 TLE -
testcase_15 TLE -
testcase_16 AC 92 ms
71,508 KB
testcase_17 AC 700 ms
91,220 KB
testcase_18 AC 831 ms
93,964 KB
testcase_19 AC 1,483 ms
104,664 KB
testcase_20 AC 1,812 ms
120,636 KB
testcase_21 AC 1,953 ms
116,740 KB
testcase_22 TLE -
testcase_23 AC 1,598 ms
121,260 KB
testcase_24 AC 1,777 ms
117,304 KB
testcase_25 AC 1,233 ms
105,232 KB
testcase_26 AC 961 ms
93,964 KB
testcase_27 AC 1,918 ms
118,120 KB
testcase_28 AC 1,223 ms
99,716 KB
testcase_29 AC 1,178 ms
94,776 KB
testcase_30 AC 1,051 ms
97,776 KB
testcase_31 AC 1,957 ms
135,996 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 1,695 ms
112,196 KB
testcase_36 AC 1,725 ms
113,460 KB
権限があれば一括ダウンロードができます

ソースコード

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