結果
問題 | No.2404 Vertical Throw Up |
ユーザー | Navier_Boltzmann |
提出日時 | 2023-08-05 17:49:07 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 294 ms / 2,000 ms |
コード長 | 1,930 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 112,640 KB |
最終ジャッジ日時 | 2024-10-15 14:51:33 |
合計ジャッジ時間 | 6,191 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
55,296 KB |
testcase_01 | AC | 47 ms
55,808 KB |
testcase_02 | AC | 53 ms
55,808 KB |
testcase_03 | AC | 238 ms
99,456 KB |
testcase_04 | AC | 223 ms
97,536 KB |
testcase_05 | AC | 290 ms
110,848 KB |
testcase_06 | AC | 57 ms
61,824 KB |
testcase_07 | AC | 294 ms
112,640 KB |
testcase_08 | AC | 235 ms
98,688 KB |
testcase_09 | AC | 233 ms
92,240 KB |
testcase_10 | AC | 172 ms
81,028 KB |
testcase_11 | AC | 155 ms
80,768 KB |
testcase_12 | AC | 138 ms
79,840 KB |
testcase_13 | AC | 68 ms
68,096 KB |
testcase_14 | AC | 76 ms
73,728 KB |
testcase_15 | AC | 78 ms
72,704 KB |
testcase_16 | AC | 67 ms
68,352 KB |
testcase_17 | AC | 87 ms
76,160 KB |
testcase_18 | AC | 92 ms
76,544 KB |
testcase_19 | AC | 68 ms
68,864 KB |
testcase_20 | AC | 69 ms
68,096 KB |
testcase_21 | AC | 89 ms
76,928 KB |
testcase_22 | AC | 68 ms
68,992 KB |
testcase_23 | AC | 63 ms
66,688 KB |
testcase_24 | AC | 75 ms
72,832 KB |
testcase_25 | AC | 60 ms
66,048 KB |
testcase_26 | AC | 77 ms
72,832 KB |
testcase_27 | AC | 77 ms
73,216 KB |
testcase_28 | AC | 64 ms
66,048 KB |
testcase_29 | AC | 58 ms
62,592 KB |
testcase_30 | AC | 53 ms
56,448 KB |
testcase_31 | AC | 66 ms
68,224 KB |
testcase_32 | AC | 57 ms
63,232 KB |
ソースコード
# import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') from collections import * from itertools import * from functools import * from heapq import * import sys,math # sys.setrecursionlimit(10**6) input = sys.stdin.readline a = int(input()) Q = int(input()) query = [tuple(map(int,input().split())) for _ in range(Q)] class CHT: def __init__(self, X: list) -> None: X = sorted([*set(X)]) self.inf = 10 ** 18 self.n = 1 << (len(X) - 1).bit_length() self.X =X + [self.inf] * (self.n - len(X)) self.D = {a: i for i, a in enumerate(X)} self.lmr = [(0, 0, 0)] * self.n + [(x, x, x) for x in self.X] for i in range(1, self.n)[::-1]: self.lmr[i] = (self.lmr[i * 2][0], self.lmr[i * 2][2], self.lmr[i * 2 ^ 1][2]) self.F = [None] * (self.n * 2) def calc(self, f: tuple, x: int) -> int: a, b = f return a * x + b def _update(self, i, f): while True: l, m, r = self.lmr[i] fi = self.F[i] if fi is None: self.F[i] = f return cl = self.calc(fi, l) > self.calc(f, l) cr = self.calc(fi, r) > self.calc(f, r) cm = self.calc(fi, m) > self.calc(f, m) if cl and cr: self.F[i] = f return if not cl and not cr: return if cm: self.F[i], f = f, fi cl = not cl if cl: i *= 2 else: i = i * 2 + 1 def query(self, x): i = self.D[x] + self.n mi = self.inf while i > 0: if self.F[i]: mi = min(mi, self.calc(self.F[i], x)) i >>= 1 return mi def add_line(self, a, b): f = (a, b) self._update(1, f) X = [] for q in query: if q[0]==2: t = q[1] X.append(t) cht = CHT(X) for q in query: if q[0]==1: s,t = q[1:] A = -a*(s+t) B = a*s*t cht.add_line(A,B) else: t = q[1] print(max(-a*t**2 - cht.query(t),0))