結果

問題 No.2404 Vertical Throw Up
ユーザー 👑 timitimi
提出日時 2024-02-28 13:49:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 273 ms / 2,000 ms
コード長 1,703 bytes
コンパイル時間 2,842 ms
コンパイル使用メモリ 81,444 KB
実行使用メモリ 100,852 KB
最終ジャッジ日時 2024-02-28 13:49:45
合計ジャッジ時間 6,914 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 220 ms
91,124 KB
testcase_04 AC 192 ms
89,328 KB
testcase_05 AC 248 ms
99,120 KB
testcase_06 AC 38 ms
53,460 KB
testcase_07 AC 273 ms
100,852 KB
testcase_08 AC 212 ms
91,120 KB
testcase_09 AC 207 ms
88,288 KB
testcase_10 AC 126 ms
78,960 KB
testcase_11 AC 125 ms
79,216 KB
testcase_12 AC 111 ms
78,460 KB
testcase_13 AC 46 ms
61,820 KB
testcase_14 AC 54 ms
66,096 KB
testcase_15 AC 52 ms
65,964 KB
testcase_16 AC 46 ms
61,820 KB
testcase_17 AC 61 ms
68,296 KB
testcase_18 AC 58 ms
68,152 KB
testcase_19 AC 44 ms
61,528 KB
testcase_20 AC 45 ms
61,528 KB
testcase_21 AC 57 ms
68,192 KB
testcase_22 AC 47 ms
61,820 KB
testcase_23 AC 45 ms
61,448 KB
testcase_24 AC 56 ms
68,304 KB
testcase_25 AC 45 ms
61,448 KB
testcase_26 AC 52 ms
66,092 KB
testcase_27 AC 57 ms
66,220 KB
testcase_28 AC 43 ms
61,448 KB
testcase_29 AC 41 ms
53,460 KB
testcase_30 AC 36 ms
53,460 KB
testcase_31 AC 45 ms
61,536 KB
testcase_32 AC 38 ms
55,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 1 << 60
class LiChaoTree(object):
    def __init__(self, X):
        X = sorted(set(X))
        N = 1 << (len(X) - 1).bit_length()
        self._tree = [None] * (N << 1)
        self._N, self._X = N, X + [INF] * (N - len(X))
        self._X_inv = {x : i for i, x in enumerate(X)}

    def add_line(self, a, b):
        tree, X = self._tree, self._X
        i, l, r = 1, 0, self._N
        while r - l:
            if tree[i] is None:
                tree[i] = (a, b)
                return
            m = (l + r) >> 1
            xl, xm, xr = X[l], X[m], X[r-1]
            ai, bi = tree[i]
            left = a * xl + b < ai * xl + bi
            mid = a * xm + b < ai * xm + bi
            right = a * xr + b < ai * xr + bi

            if left is right:
                if left:
                    tree[i] = (a, b)
                return
            if mid:
                tree[i], a, b = (a, b), ai, bi
            if left is not mid:
                i, r = i << 1, m
            else:
                i, l = i << 1 | 1, m

    def get_min(self, x):
        i = self._X_inv[x]
        i += self._N
        res = INF
        tree = self._tree
        while i:
            if tree[i] is not None:
                a, b = tree[i]
                res = min(res, a * x + b)
            i >>= 1
        return res

from sys import stdin
input=lambda :stdin.readline()[:-1]


a=int(input())
Q=int(input())
S=[]
X=set()
for _ in range(Q):
  t,*A=list(map(int, input().split()))
  if t==2:
    X.add(A[0])
  S.append((t,*A))

LCT=LiChaoTree(X)
for query in S:
  if query[0]==1:
    s,t=query[1:]
    LCT.add_line(-(s+t),s*t)
  else:
    t=query[1]
    ans=max(0,-LCT.get_min(t)-t*t)
    print(ans*a)
0