結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー keijakkeijak
提出日時 2020-10-09 21:42:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 782 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 98,004 KB
最終ジャッジ日時 2023-09-27 15:56:20
合計ジャッジ時間 20,845 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,240 KB
testcase_01 AC 71 ms
71,152 KB
testcase_02 AC 75 ms
75,816 KB
testcase_03 AC 74 ms
75,948 KB
testcase_04 AC 76 ms
76,016 KB
testcase_05 AC 75 ms
76,016 KB
testcase_06 AC 75 ms
75,840 KB
testcase_07 AC 75 ms
75,924 KB
testcase_08 AC 74 ms
75,844 KB
testcase_09 AC 76 ms
75,776 KB
testcase_10 AC 75 ms
75,888 KB
testcase_11 AC 75 ms
75,776 KB
testcase_12 AC 74 ms
75,684 KB
testcase_13 AC 76 ms
75,596 KB
testcase_14 AC 74 ms
75,944 KB
testcase_15 AC 77 ms
75,844 KB
testcase_16 AC 76 ms
75,844 KB
testcase_17 AC 77 ms
75,748 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
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 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 72 ms
71,412 KB
testcase_44 AC 75 ms
75,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    A = inl()
    B = inl()

    def f(x):
        res = 0
        for i in range(n):
            res += B[i] * abs(x - A[i])
        return res

    lo, hi, fhi = min(A) - 1, max(A) + 1, None
    for i in range(100):
        x = lo + (hi - lo) / 3.0
        y = lo + (hi - lo) * 2.0 / 3.0
        fx, fy = f(x), f(y)
        if fx > fy:
            lo = x
        else:
            hi = y
            fhi = fx
    return "{:.9f}".format(hi), int(fhi + 0.5)


print(*solve())
0