結果
問題 | No.703 ゴミ拾い Easy |
ユーザー | satama6 |
提出日時 | 2023-02-12 12:19:53 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,672 bytes |
コンパイル時間 | 733 ms |
コンパイル使用メモリ | 86,440 KB |
実行使用メモリ | 176,188 KB |
最終ジャッジ日時 | 2023-09-23 04:33:09 |
合計ジャッジ時間 | 18,107 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 76 ms
71,204 KB |
testcase_01 | AC | 75 ms
71,204 KB |
testcase_02 | AC | 76 ms
71,240 KB |
testcase_03 | AC | 77 ms
71,284 KB |
testcase_04 | WA | - |
testcase_05 | AC | 74 ms
71,276 KB |
testcase_06 | AC | 75 ms
71,068 KB |
testcase_07 | AC | 77 ms
71,164 KB |
testcase_08 | WA | - |
testcase_09 | AC | 76 ms
71,292 KB |
testcase_10 | WA | - |
testcase_11 | AC | 76 ms
71,240 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 120 ms
76,512 KB |
testcase_15 | AC | 97 ms
76,480 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 99 ms
76,556 KB |
testcase_20 | AC | 99 ms
76,676 KB |
testcase_21 | WA | - |
testcase_22 | AC | 104 ms
77,480 KB |
testcase_23 | AC | 104 ms
77,112 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 409 ms
176,100 KB |
testcase_35 | AC | 358 ms
175,756 KB |
testcase_36 | AC | 368 ms
176,176 KB |
testcase_37 | AC | 375 ms
175,868 KB |
testcase_38 | AC | 372 ms
175,876 KB |
testcase_39 | AC | 367 ms
175,828 KB |
testcase_40 | AC | 370 ms
175,760 KB |
testcase_41 | AC | 398 ms
176,052 KB |
testcase_42 | AC | 361 ms
175,664 KB |
testcase_43 | AC | 392 ms
176,188 KB |
testcase_44 | AC | 75 ms
71,196 KB |
testcase_45 | AC | 75 ms
71,184 KB |
testcase_46 | AC | 365 ms
171,084 KB |
testcase_47 | AC | 362 ms
172,468 KB |
testcase_48 | WA | - |
testcase_49 | WA | - |
ソースコード
class LiChaoTree: def __init__(self, M, A) -> None: """ 最小値クエリで聞かれる{x1, ..., xn}が既知の時(クエリ先読み) """ self.M = M # クエリ数 l = 1 while l < M: l <<= 1 self.length = l self.sg = [None] * (2 * l) # (a, b)直線 self.X = [1 << 60] * l self.update_X(A) def update_X(self, A): self.X = A + [1 << 60] * (self.length - self.M) def get_value(self, line, x): """座標xにおける直線lineの値 """ return line[0] * x + line[1] def _add_line(self, line, k, l, r): """トップダウンに更新 右、左、真ん中を比較して、lineが必要か不要かを判定 Parameter ----------- k: 現在処理している区間に対応するセグ木上のインデックス l: 現在処理している区間に対応する座標の左端 r: 現在処理している区間に対応する座標の右端 """ if self.sg[k] == None : self.sg[k] = line; return m = (l + r) // 2 lx, mx, rx = self.X[l], self.X[m], self.X[r-1] left = self.get_value(line, lx) < self.get_value(self.sg[k], lx) # 左端 middle = self.get_value(line, mx) < self.get_value(self.sg[k], mx) # 真ん中 right = self.get_value(line, rx) < self.get_value(self.sg[k], rx) # 右端 # 元々の直線よりもlineの方が値が小さい if left and right:self.sg[k] = line; return # 元々の直線の方がlineよりも値が小さい elif not (left or right) : return # 元々の直線とlineが交わっている、かつ真ん中でlineの方が小さい if middle : self.sg[k], line = line, self.sg[k] # 左側をlineに更新しなければならない if left != middle : self._add_line(line, 2*k, l, m) # 右側をlineに更新しなければならない else : self._add_line(line, 2*k+1, m, r) def add_line(self, line): self._add_line(line, 1, 0, self.M) def gen(self, k, x): k += self.length while k > 0: if self.sg[k] is not None : yield self.get_value(self.sg[k], x) k >>= 1 def query(self, k, x): return min(self.gen(k, x)) N = int(input()) A = list(map(int, input().split())) X = list(map(int, input().split())) Y = list(map(int, input().split())) lichao = LiChaoTree(N, A) v = 0 for i in range(N): lichao.add_line((-2*X[i], X[i]**2 + Y[i]**2 + v)) v = lichao.query(i, A[i]) + A[i]**2 print(v)