結果
問題 | No.618 labo-index |
ユーザー | mkawa2 |
提出日時 | 2021-12-05 02:02:20 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,268 bytes |
コンパイル時間 | 395 ms |
コンパイル使用メモリ | 86,660 KB |
実行使用メモリ | 270,664 KB |
最終ジャッジ日時 | 2023-09-21 13:13:15 |
合計ジャッジ時間 | 26,523 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 79 ms
71,384 KB |
testcase_01 | AC | 78 ms
71,228 KB |
testcase_02 | AC | 81 ms
71,152 KB |
testcase_03 | AC | 81 ms
70,964 KB |
testcase_04 | AC | 126 ms
77,200 KB |
testcase_05 | AC | 139 ms
77,272 KB |
testcase_06 | AC | 81 ms
71,108 KB |
testcase_07 | AC | 90 ms
74,828 KB |
testcase_08 | AC | 90 ms
75,400 KB |
testcase_09 | AC | 108 ms
76,368 KB |
testcase_10 | AC | 122 ms
77,164 KB |
testcase_11 | AC | 102 ms
75,732 KB |
testcase_12 | AC | 98 ms
75,732 KB |
testcase_13 | AC | 116 ms
77,160 KB |
testcase_14 | AC | 104 ms
76,272 KB |
testcase_15 | AC | 118 ms
77,136 KB |
testcase_16 | AC | 129 ms
77,332 KB |
testcase_17 | AC | 99 ms
76,024 KB |
testcase_18 | AC | 176 ms
78,752 KB |
testcase_19 | AC | 767 ms
92,376 KB |
testcase_20 | AC | 873 ms
94,740 KB |
testcase_21 | AC | 816 ms
92,780 KB |
testcase_22 | AC | 748 ms
93,616 KB |
testcase_23 | AC | 851 ms
94,064 KB |
testcase_24 | AC | 817 ms
94,528 KB |
testcase_25 | AC | 865 ms
93,128 KB |
testcase_26 | AC | 813 ms
92,644 KB |
testcase_27 | AC | 762 ms
92,340 KB |
testcase_28 | AC | 711 ms
92,504 KB |
testcase_29 | AC | 835 ms
92,632 KB |
testcase_30 | AC | 771 ms
91,708 KB |
testcase_31 | AC | 785 ms
93,532 KB |
testcase_32 | AC | 923 ms
94,464 KB |
testcase_33 | AC | 842 ms
94,676 KB |
testcase_34 | AC | 269 ms
95,272 KB |
testcase_35 | AC | 326 ms
101,368 KB |
testcase_36 | TLE | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = 18446744073709551615 inf = 4294967295 md = 10**9+7 # md = 998244353 from heapq import * class RemovableHeap: def __init__(self): self.hp = [] self.rem = [] self.s = {} self.size = 0 def __len__(self): return self.size def __getitem__(self, i): if i: return None self.__trim() return self.hp[0] def push(self, val): heappush(self.hp, val) if val in self.s: self.s[val] += 1 else: self.s[val] = 1 self.size += 1 return True def pop(self): self.__trim() if not self.hp: return None self.size -= 1 val = heappop(self.hp) if self.s[val] == 1: del self.s[val] else: self.s[val] -= 1 return val def remove(self, val): if val not in self.s: return False self.size -= 1 if self.s[val] == 1: del self.s[val] else: self.s[val] -= 1 heappush(self.rem, val) return True def __trim(self): while self.rem and self.rem[0] == self.hp[0]: heappop(self.hp) heappop(self.rem) ll = RemovableHeap() rr = RemovableHeap() q = II() base = 0 xx = [] for _ in range(q): t, x = LI() if t == 1: x -= base if len(rr) and x >= rr[0]: rr.push(x) else: ll.push(-x) xx.append(x) if t == 2: x = xx[x-1] if len(rr) and x >= rr[0]: rr.remove(x) else: ll.remove(-x) if t == 3: base += x while len(ll) and -ll[0]+base > len(rr): x = -ll.pop() rr.push(x) while len(rr) and rr[0]+base < len(rr): x = rr.pop() ll.push(-x) print(len(rr))