結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー Coki628Coki628
提出日時 2020-12-04 00:20:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,151 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 87,648 KB
実行使用メモリ 115,328 KB
最終ジャッジ日時 2023-10-12 10:54:16
合計ジャッジ時間 9,465 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 78 ms
71,632 KB
testcase_02 AC 80 ms
76,016 KB
testcase_03 AC 80 ms
76,032 KB
testcase_04 AC 81 ms
76,176 KB
testcase_05 AC 81 ms
75,868 KB
testcase_06 WA -
testcase_07 AC 81 ms
76,052 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 76 ms
75,988 KB
testcase_11 AC 76 ms
75,868 KB
testcase_12 AC 78 ms
76,040 KB
testcase_13 WA -
testcase_14 AC 78 ms
76,148 KB
testcase_15 AC 78 ms
76,152 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

def trisearch_min(lo, hi, func):
    """ 三分探索 """

    while lo+2 < hi:
        m1 = (lo*2+hi) // 3
        m2 = (lo+hi*2) // 3
        res1 = func(m1)
        res2 = func(m2)
        if res1 <= res2:
            hi = m2
        else:
            lo = m1
    return m1, m2

N = INT()
A = LIST()
B = LIST()

def check(m):
    res = 0
    for i in range(N):
        res += B[i] * abs(m-A[i])
    return res

res = trisearch_min(-INF, INF, check)
ans = check(res[0])
print(res[0], ans)
0