結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー tonyu0tonyu0
提出日時 2020-10-09 22:07:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 400 bytes
コンパイル時間 345 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 110,820 KB
最終ジャッジ日時 2023-09-27 17:21:10
合計ジャッジ時間 21,853 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,448 KB
testcase_01 AC 71 ms
71,408 KB
testcase_02 AC 93 ms
75,912 KB
testcase_03 AC 75 ms
75,548 KB
testcase_04 AC 77 ms
75,876 KB
testcase_05 AC 76 ms
75,788 KB
testcase_06 AC 76 ms
75,584 KB
testcase_07 AC 76 ms
75,896 KB
testcase_08 AC 76 ms
75,648 KB
testcase_09 AC 76 ms
75,556 KB
testcase_10 AC 75 ms
75,692 KB
testcase_11 AC 76 ms
75,816 KB
testcase_12 AC 76 ms
76,004 KB
testcase_13 AC 76 ms
75,540 KB
testcase_14 AC 76 ms
75,812 KB
testcase_15 AC 74 ms
75,692 KB
testcase_16 AC 76 ms
75,764 KB
testcase_17 AC 75 ms
75,772 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 71 ms
71,380 KB
testcase_44 AC 75 ms
75,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


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


l = -1e9
r = 1e9

for i in range(100):
    llr = (l + l + r) / 3
    lrr = (l + r + r) / 3
    vl = f(llr)
    vr = f(lrr)
    if vl > vr:
        l = llr
    else:
        r = lrr

print(round(l), round(f(l)))
0