結果
問題 | No.1675 Strange Minimum Query |
ユーザー | H3PO4 |
提出日時 | 2021-09-10 22:57:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,410 bytes |
コンパイル時間 | 290 ms |
コンパイル使用メモリ | 87,120 KB |
実行使用メモリ | 201,432 KB |
最終ジャッジ日時 | 2023-09-02 20:33:49 |
合計ジャッジ時間 | 15,605 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 77 ms
71,120 KB |
testcase_01 | AC | 75 ms
71,276 KB |
testcase_02 | AC | 77 ms
71,348 KB |
testcase_03 | AC | 286 ms
112,240 KB |
testcase_04 | AC | 271 ms
109,104 KB |
testcase_05 | AC | 121 ms
85,800 KB |
testcase_06 | AC | 330 ms
120,400 KB |
testcase_07 | AC | 370 ms
123,624 KB |
testcase_08 | AC | 78 ms
71,184 KB |
testcase_09 | AC | 116 ms
78,244 KB |
testcase_10 | AC | 454 ms
115,392 KB |
testcase_11 | AC | 228 ms
90,776 KB |
testcase_12 | AC | 491 ms
119,380 KB |
testcase_13 | AC | 674 ms
186,896 KB |
testcase_14 | AC | 638 ms
201,432 KB |
testcase_15 | AC | 743 ms
190,832 KB |
testcase_16 | AC | 76 ms
71,348 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
ソースコード
import sys import heapq input = sys.stdin.buffer.readline class Set_min(set): def __init__(self, iterable=tuple()): super(Set_min, self).__init__(iterable) self.h = list(set(iterable)) heapq.heapify(self.h) def add(self, x): super(Set_min, self).add(x) heapq.heappush(self.h, x) def remove(self, x): super(Set_min, self).remove(x) def min(self): if not super(Set_min, self).__len__(): raise ValueError while self.h and self.h[0] not in self: heapq.heappop(self.h) return self.h[0] N, Q = map(int, input().split()) MAX = 10 ** 9 h = [] queries = [[] for _ in range(N + 1)] for i in range(Q): l, r, b = map(int, input().split()) l -= 1 queries[l].append((b, i, 1)) queries[r].append((b, i, 2)) ans = [MAX] * N st1 = Set_min() st2 = Set_min() for i in range(N): for b, j, f in queries[i]: if f == 1: st1.add((-b, j)) else: # assert f == 2 if (-b, j) in st1: print(-1) exit() else: st2.remove((-b, j)) if st1: q = st1.min() if st2 and -q[0] < -st2.min()[0]: continue st1.remove(q) ans[i] = -q[0] st2.add(q) for b, j, f in queries[N]: if (-b, j) in st1: print(-1) exit() print(*ans)