結果

問題 No.703 ゴミ拾い Easy
ユーザー tjaketjake
提出日時 2018-06-15 23:43:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,123 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 196,364 KB
最終ジャッジ日時 2023-09-13 05:24:45
合計ジャッジ時間 14,506 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,668 KB
testcase_01 AC 64 ms
71,440 KB
testcase_02 AC 67 ms
71,404 KB
testcase_03 AC 65 ms
71,148 KB
testcase_04 WA -
testcase_05 AC 66 ms
71,536 KB
testcase_06 AC 67 ms
71,356 KB
testcase_07 AC 67 ms
71,464 KB
testcase_08 WA -
testcase_09 AC 67 ms
71,152 KB
testcase_10 WA -
testcase_11 AC 65 ms
71,308 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 81 ms
76,252 KB
testcase_15 AC 84 ms
76,516 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 81 ms
76,252 KB
testcase_20 AC 85 ms
76,404 KB
testcase_21 WA -
testcase_22 AC 86 ms
76,400 KB
testcase_23 AC 84 ms
76,268 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 402 ms
195,924 KB
testcase_35 AC 351 ms
195,728 KB
testcase_36 AC 355 ms
195,580 KB
testcase_37 AC 369 ms
195,552 KB
testcase_38 AC 353 ms
196,364 KB
testcase_39 AC 349 ms
195,372 KB
testcase_40 AC 369 ms
196,060 KB
testcase_41 AC 372 ms
195,552 KB
testcase_42 AC 356 ms
196,012 KB
testcase_43 AC 373 ms
195,516 KB
testcase_44 AC 66 ms
71,412 KB
testcase_45 AC 67 ms
71,384 KB
testcase_46 AC 319 ms
179,792 KB
testcase_47 AC 343 ms
177,492 KB
testcase_48 WA -
testcase_49 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
*A, = map(int, input().split())
*X, = map(int, input().split())
*Y, = map(int, input().split())

N0 = 2**(N-1).bit_length()
data = [None]*(2*N0)

# Li Chao Tree
def f(line, x):
    p, q = line
    return p*x + q

def _add_line(line, k, l, r):
    m = (l + r) // 2
    if data[k] is None:
        data[k] = line
        return
    lx = A[l]
    mx = A[m]
    rx = A[r-1]
    left = (f(line, lx) < f(data[k], lx))
    mid = (f(line, mx) < f(data[k], mx))
    right = (f(line, rx) < f(data[k], rx))
    if left and right:
        data[k] = line
        return
    if not left and not right:
        return
    if mid:
        data[k], line = line, data[k]
    if left != mid:
        _add_line(line, 2*k+1, l, m)
    else:
        _add_line(line, 2*k+2, m, r)

def add_line(line):
    return _add_line(line, 0, 0, N)

def query(k, x):
    k += N0-1
    s = 1e30
    while k >= 0:
        if data[k]:
            s = min(s, f(data[k], x))
        k = (k - 1) // 2
    return s

v = 0
for i in range(N):
    x = X[i]; a = A[i]; y = Y[i]
    add_line((-2*x, x**2 + y**2 + v))
    v = query(i, a) + a**2
print(v)
0