結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,536 KB
testcase_01 AC 68 ms
75,776 KB
testcase_02 AC 71 ms
76,076 KB
testcase_03 AC 71 ms
76,144 KB
testcase_04 AC 71 ms
75,896 KB
testcase_05 AC 69 ms
76,164 KB
testcase_06 AC 72 ms
76,196 KB
testcase_07 AC 70 ms
76,004 KB
testcase_08 AC 70 ms
76,132 KB
testcase_09 AC 69 ms
76,076 KB
testcase_10 AC 70 ms
75,892 KB
testcase_11 AC 69 ms
75,952 KB
testcase_12 AC 70 ms
76,152 KB
testcase_13 AC 68 ms
75,776 KB
testcase_14 AC 71 ms
75,976 KB
testcase_15 AC 68 ms
76,008 KB
testcase_16 AC 68 ms
75,812 KB
testcase_17 AC 67 ms
76,128 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 68 ms
75,208 KB
testcase_44 AC 69 ms
76,036 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(300):
        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