結果
問題 | No.2220 Range Insert & Point Mex |
ユーザー | rlangevin |
提出日時 | 2023-02-17 22:49:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 809 ms / 2,000 ms |
コード長 | 1,496 bytes |
コンパイル時間 | 399 ms |
コンパイル使用メモリ | 86,948 KB |
実行使用メモリ | 126,240 KB |
最終ジャッジ日時 | 2023-09-28 18:12:31 |
合計ジャッジ時間 | 17,741 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 111 ms
83,440 KB |
testcase_01 | AC | 114 ms
83,480 KB |
testcase_02 | AC | 108 ms
83,604 KB |
testcase_03 | AC | 112 ms
83,400 KB |
testcase_04 | AC | 111 ms
83,300 KB |
testcase_05 | AC | 109 ms
83,484 KB |
testcase_06 | AC | 109 ms
83,224 KB |
testcase_07 | AC | 111 ms
83,324 KB |
testcase_08 | AC | 111 ms
83,228 KB |
testcase_09 | AC | 115 ms
83,328 KB |
testcase_10 | AC | 116 ms
83,408 KB |
testcase_11 | AC | 111 ms
83,136 KB |
testcase_12 | AC | 111 ms
83,388 KB |
testcase_13 | AC | 727 ms
111,328 KB |
testcase_14 | AC | 809 ms
111,408 KB |
testcase_15 | AC | 721 ms
111,540 KB |
testcase_16 | AC | 709 ms
110,892 KB |
testcase_17 | AC | 691 ms
111,212 KB |
testcase_18 | AC | 717 ms
111,140 KB |
testcase_19 | AC | 719 ms
111,036 KB |
testcase_20 | AC | 487 ms
110,784 KB |
testcase_21 | AC | 488 ms
111,488 KB |
testcase_22 | AC | 497 ms
111,040 KB |
testcase_23 | AC | 372 ms
116,972 KB |
testcase_24 | AC | 351 ms
107,648 KB |
testcase_25 | AC | 398 ms
100,952 KB |
testcase_26 | AC | 363 ms
126,240 KB |
testcase_27 | AC | 335 ms
120,128 KB |
testcase_28 | AC | 147 ms
97,532 KB |
testcase_29 | AC | 151 ms
98,180 KB |
testcase_30 | AC | 147 ms
98,472 KB |
testcase_31 | AC | 225 ms
102,292 KB |
testcase_32 | AC | 355 ms
106,644 KB |
testcase_33 | AC | 517 ms
106,500 KB |
testcase_34 | AC | 628 ms
110,368 KB |
testcase_35 | AC | 801 ms
110,616 KB |
testcase_36 | AC | 618 ms
107,680 KB |
testcase_37 | AC | 767 ms
108,020 KB |
testcase_38 | AC | 464 ms
110,784 KB |
ソースコード
import sys readline = sys.stdin.readline from heapq import * from collections import * class QuasiBinaryTree: def __init__(self, rule="min"): if rule == "max": self.pm = -1 else: self.pm = 1 self.inf = 10**18 self.P = [self.inf] self.Q = [] def insert(self, x): heappush(self.P, x * self.pm) def erase(self, x): heappush(self.Q, x * self.pm) def top(self): while self.Q and (self.P[0] == self.Q[0]): heappop(self.P) heappop(self.Q) return self.P[0] * self.pm def f(r, a): return r * M + a N = int(readline()) M = 10 ** 9 + 7 lst = [] for i in range(N): L, R, A = map(int, readline().split()) lst.append((L, R, A)) lst.sort(reverse=True) Q = int(readline()) X = list(map(int, readline().split())) H = [] S = QuasiBinaryTree("min") for i in range(101010): S.insert(i) cnt = defaultdict(int) for x in X: while lst: L, R, A = lst[-1] if A >= 100010: lst.pop() continue if L <= x: heappush(H, (R, A)) cnt[A] += 1 if cnt[A] == 1: S.erase(A) lst.pop() else: break while H: R, A = H[0] if R < x: cnt[A] -= 1 if cnt[A] == 0: S.insert(A) heappop(H) else: break print(S.top())