結果
問題 | No.704 ゴミ拾い Medium |
ユーザー | tjake |
提出日時 | 2018-06-16 00:09:54 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,445 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 87,124 KB |
実行使用メモリ | 182,984 KB |
最終ジャッジ日時 | 2023-09-13 05:33:02 |
合計ジャッジ時間 | 7,428 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
71,500 KB |
testcase_01 | AC | 70 ms
71,364 KB |
testcase_02 | AC | 70 ms
71,448 KB |
testcase_03 | AC | 71 ms
71,356 KB |
testcase_04 | AC | 75 ms
71,456 KB |
testcase_05 | WA | - |
testcase_06 | AC | 70 ms
71,384 KB |
testcase_07 | AC | 69 ms
71,068 KB |
testcase_08 | AC | 70 ms
71,272 KB |
testcase_09 | WA | - |
testcase_10 | AC | 69 ms
71,360 KB |
testcase_11 | AC | 69 ms
71,372 KB |
testcase_12 | AC | 69 ms
71,480 KB |
testcase_13 | AC | 70 ms
71,556 KB |
testcase_14 | AC | 139 ms
78,124 KB |
testcase_15 | AC | 117 ms
77,444 KB |
testcase_16 | AC | 144 ms
79,456 KB |
testcase_17 | AC | 131 ms
78,072 KB |
testcase_18 | AC | 146 ms
78,444 KB |
testcase_19 | AC | 176 ms
79,776 KB |
testcase_20 | AC | 145 ms
78,436 KB |
testcase_21 | AC | 133 ms
77,964 KB |
testcase_22 | AC | 118 ms
77,724 KB |
testcase_23 | AC | 153 ms
78,948 KB |
testcase_24 | TLE | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
ソースコード
N = int(input()) *A, = map(int, input().split()) *X, = map(int, input().split()) *Y, = map(int, input().split()) N0 = 2**(N-1).bit_length() A = A + [10**6] * (N0 - N) data = [None]*(2*N0+1) # Li Chao Tree def f(line, x): p, q = line return p*x + q def _add_line(line, a, b, k, l, r): if r <= a or b <= l: return m = (l + r) // 2 if not (a <= l and r <= b): _add_line(line, a, b, 2*k+1, l, m) _add_line(line, a, b, 2*k+2, m, r) return 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, a, b): return _add_line(line, a, b, 0, 0, N0) def query(k, x): def gen(k, x): k += N0-1 while k >= 0: if data[k]: yield f(data[k], x) k = (k - 1) // 2 return min(gen(k, x)) v = 0 j = 0 for i in range(N): x = X[i]; a = A[i]; y = Y[i] while A[j+1] < x: j += 1 add_line((-1, x+y+v), 0, j+1) add_line((1, -x+y+v), j+1, N0) v = query(i, a) print(v)