結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー tonyu0tonyu0
提出日時 2020-10-09 22:09:20
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 403 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 111,184 KB
最終ジャッジ日時 2023-09-27 17:31:38
合計ジャッジ時間 57,487 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
76,164 KB
testcase_01 AC 82 ms
76,644 KB
testcase_02 AC 81 ms
76,348 KB
testcase_03 AC 80 ms
76,364 KB
testcase_04 AC 86 ms
76,608 KB
testcase_05 AC 81 ms
76,624 KB
testcase_06 AC 80 ms
76,416 KB
testcase_07 AC 83 ms
76,512 KB
testcase_08 AC 81 ms
76,684 KB
testcase_09 AC 81 ms
76,252 KB
testcase_10 AC 80 ms
76,484 KB
testcase_11 AC 80 ms
76,476 KB
testcase_12 AC 81 ms
76,252 KB
testcase_13 AC 80 ms
76,256 KB
testcase_14 AC 82 ms
76,252 KB
testcase_15 AC 80 ms
76,420 KB
testcase_16 AC 82 ms
76,256 KB
testcase_17 AC 81 ms
76,364 KB
testcase_18 TLE -
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 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 AC 82 ms
76,516 KB
testcase_44 AC 81 ms
76,420 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 = -1e18
r = 1e18

for i in range(1000):
    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