結果
問題 | No.618 labo-index |
ユーザー | mkawa2 |
提出日時 | 2021-12-05 02:02:20 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,268 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 82,184 KB |
実行使用メモリ | 99,476 KB |
最終ジャッジ日時 | 2024-07-07 06:56:14 |
合計ジャッジ時間 | 20,655 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
54,444 KB |
testcase_01 | AC | 36 ms
53,240 KB |
testcase_02 | AC | 35 ms
53,136 KB |
testcase_03 | AC | 34 ms
53,620 KB |
testcase_04 | AC | 75 ms
76,120 KB |
testcase_05 | AC | 84 ms
76,540 KB |
testcase_06 | AC | 36 ms
53,728 KB |
testcase_07 | AC | 41 ms
60,632 KB |
testcase_08 | AC | 44 ms
62,760 KB |
testcase_09 | AC | 58 ms
69,924 KB |
testcase_10 | AC | 72 ms
76,444 KB |
testcase_11 | AC | 54 ms
66,732 KB |
testcase_12 | AC | 50 ms
66,044 KB |
testcase_13 | AC | 64 ms
72,956 KB |
testcase_14 | AC | 55 ms
69,060 KB |
testcase_15 | AC | 67 ms
73,960 KB |
testcase_16 | AC | 82 ms
76,540 KB |
testcase_17 | AC | 50 ms
66,508 KB |
testcase_18 | AC | 118 ms
77,616 KB |
testcase_19 | AC | 576 ms
89,668 KB |
testcase_20 | AC | 643 ms
91,220 KB |
testcase_21 | AC | 623 ms
89,752 KB |
testcase_22 | AC | 545 ms
88,904 KB |
testcase_23 | AC | 629 ms
89,724 KB |
testcase_24 | AC | 602 ms
90,372 KB |
testcase_25 | AC | 649 ms
91,408 KB |
testcase_26 | AC | 602 ms
89,720 KB |
testcase_27 | AC | 575 ms
88,872 KB |
testcase_28 | AC | 514 ms
88,388 KB |
testcase_29 | AC | 611 ms
89,416 KB |
testcase_30 | AC | 560 ms
89,476 KB |
testcase_31 | AC | 578 ms
89,280 KB |
testcase_32 | AC | 690 ms
91,328 KB |
testcase_33 | AC | 605 ms
90,152 KB |
testcase_34 | AC | 184 ms
95,084 KB |
testcase_35 | AC | 223 ms
99,476 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))