結果
問題 | No.703 ゴミ拾い Easy |
ユーザー | mkawa2 |
提出日時 | 2023-02-28 13:32:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 378 ms / 1,500 ms |
コード長 | 3,265 bytes |
コンパイル時間 | 361 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 178,752 KB |
最終ジャッジ日時 | 2024-09-15 15:45:46 |
合計ジャッジ時間 | 12,443 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
53,760 KB |
testcase_01 | AC | 46 ms
53,888 KB |
testcase_02 | AC | 45 ms
54,144 KB |
testcase_03 | AC | 46 ms
54,016 KB |
testcase_04 | AC | 46 ms
53,760 KB |
testcase_05 | AC | 46 ms
53,760 KB |
testcase_06 | AC | 45 ms
53,760 KB |
testcase_07 | AC | 46 ms
54,016 KB |
testcase_08 | AC | 45 ms
53,888 KB |
testcase_09 | AC | 46 ms
53,888 KB |
testcase_10 | AC | 45 ms
54,144 KB |
testcase_11 | AC | 46 ms
54,016 KB |
testcase_12 | AC | 46 ms
53,888 KB |
testcase_13 | AC | 46 ms
53,888 KB |
testcase_14 | AC | 57 ms
63,232 KB |
testcase_15 | AC | 58 ms
62,848 KB |
testcase_16 | AC | 57 ms
62,592 KB |
testcase_17 | AC | 58 ms
62,720 KB |
testcase_18 | AC | 59 ms
63,104 KB |
testcase_19 | AC | 59 ms
62,976 KB |
testcase_20 | AC | 58 ms
63,232 KB |
testcase_21 | AC | 59 ms
63,232 KB |
testcase_22 | AC | 59 ms
63,360 KB |
testcase_23 | AC | 57 ms
63,104 KB |
testcase_24 | AC | 366 ms
162,180 KB |
testcase_25 | AC | 369 ms
162,184 KB |
testcase_26 | AC | 378 ms
161,672 KB |
testcase_27 | AC | 378 ms
162,180 KB |
testcase_28 | AC | 362 ms
161,676 KB |
testcase_29 | AC | 363 ms
162,184 KB |
testcase_30 | AC | 368 ms
162,184 KB |
testcase_31 | AC | 371 ms
162,044 KB |
testcase_32 | AC | 363 ms
162,052 KB |
testcase_33 | AC | 375 ms
162,316 KB |
testcase_34 | AC | 252 ms
159,524 KB |
testcase_35 | AC | 247 ms
158,876 KB |
testcase_36 | AC | 247 ms
159,040 KB |
testcase_37 | AC | 248 ms
159,004 KB |
testcase_38 | AC | 248 ms
158,908 KB |
testcase_39 | AC | 247 ms
159,140 KB |
testcase_40 | AC | 245 ms
159,140 KB |
testcase_41 | AC | 248 ms
159,396 KB |
testcase_42 | AC | 247 ms
159,152 KB |
testcase_43 | AC | 244 ms
159,388 KB |
testcase_44 | AC | 46 ms
54,272 KB |
testcase_45 | AC | 46 ms
53,632 KB |
testcase_46 | AC | 260 ms
178,752 KB |
testcase_47 | AC | 252 ms
163,944 KB |
testcase_48 | AC | 57 ms
62,720 KB |
testcase_49 | AC | 58 ms
63,232 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) 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 = (1 << 63)-1 # inf = (1 << 31)-1 md = 10**9+7 # md = 998244353 from collections import deque class ConvexHullTrick: def __init__(self, getmin=1, a_inc=0, x_inc=1): self._getmin = getmin self._a_inc = a_inc self._x_inc = x_inc self._ab = deque() self._inf = (1 << 63)-1 self._px = self._inf*(-2*x_inc+1) def add_line(self, a, b): if not self._ab: self._ab.append((a, b)) return if self._getmin ^ self._a_inc: if self._ab and a == self._ab[-1][0]: if (b-self._ab[-1][1])*(self._getmin*2-1) >= 0: return self._ab.pop() if self._x_inc: while len(self._ab) > 1: c, d = self._ab.pop() e, f = self._ab[-1] if (b-d)*(e-c) > (d-f)*(c-a): self._ab.append((c, d)) break else: (c, d), x = self._ab[-1], self._px if (a*x+b-c*x-d)*(self._getmin*2-1) >= 0: return self._ab.append((a, b)) else: if self._ab and a == self._ab[0][0]: if (b-self._ab[0][1])*(self._getmin*2-1) >= 0: return self._ab.popleft() if not self._x_inc: while len(self._ab) > 1: c, d = self._ab.popleft() e, f = self._ab[0] if (b-d)*(e-c) < (d-f)*(c-a): self._ab.append((c, d)) break else: (c, d), x = self._ab[0], self._px if (a*x+b-c*x-d)*(self._getmin*2-1) >= 0: return self._ab.appendleft((a, b)) def __getitem__(self, x): self._px = x if not self._ab: return self._inf*(self._getmin*2-1) if self._x_inc: while len(self._ab) > 1: a, b = self._ab.popleft() c, d = self._ab[0] if (a*x+b-c*x-d)*(self._getmin*2-1) < 0: self._ab.appendleft((a, b)) return a*x+b else: while len(self._ab) > 1: a, b = self._ab.pop() c, d = self._ab[-1] if (a*x+b-c*x-d)*(self._getmin*2-1) < 0: self._ab.append((a, b)) return a*x+b a, b = self._ab[0] return a*x+b n = II() aa = LI() xx = LI() yy = LI() cht = ConvexHullTrick() mn = 0 for a, x, y in zip(aa, xx, yy): cht.add_line(-2*x, x**2+y**2+mn) mn = a**2+cht[a] print(mn)