結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー keijakkeijak
提出日時 2020-10-09 21:43:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 803 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 97,968 KB
最終ジャッジ日時 2023-09-27 15:59:13
合計ジャッジ時間 19,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,260 KB
testcase_01 AC 62 ms
71,240 KB
testcase_02 AC 65 ms
75,976 KB
testcase_03 AC 65 ms
75,832 KB
testcase_04 AC 66 ms
75,676 KB
testcase_05 AC 68 ms
75,980 KB
testcase_06 AC 65 ms
75,552 KB
testcase_07 AC 68 ms
75,884 KB
testcase_08 AC 68 ms
75,768 KB
testcase_09 AC 63 ms
75,804 KB
testcase_10 AC 64 ms
75,848 KB
testcase_11 AC 67 ms
75,928 KB
testcase_12 AC 68 ms
75,880 KB
testcase_13 AC 65 ms
75,652 KB
testcase_14 AC 65 ms
75,808 KB
testcase_15 AC 65 ms
75,804 KB
testcase_16 AC 66 ms
75,908 KB
testcase_17 AC 65 ms
75,836 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 63 ms
71,228 KB
testcase_44 AC 64 ms
75,980 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
            fhi = fy
        else:
            hi = y
            fhi = fx
    return "{:.9f}".format(hi), int(fhi + 0.5)


print(*solve())
0