結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー roarisroaris
提出日時 2020-11-15 10:52:49
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 407 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 109,768 KB
最終ジャッジ日時 2023-09-30 06:51:18
合計ジャッジ時間 57,817 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,284 KB
testcase_01 AC 65 ms
71,484 KB
testcase_02 AC 73 ms
76,096 KB
testcase_03 AC 71 ms
75,736 KB
testcase_04 AC 75 ms
76,156 KB
testcase_05 AC 73 ms
75,988 KB
testcase_06 AC 71 ms
75,988 KB
testcase_07 AC 76 ms
76,008 KB
testcase_08 AC 77 ms
76,200 KB
testcase_09 AC 72 ms
76,140 KB
testcase_10 AC 73 ms
75,980 KB
testcase_11 AC 73 ms
75,960 KB
testcase_12 AC 71 ms
76,248 KB
testcase_13 AC 73 ms
76,000 KB
testcase_14 AC 74 ms
75,976 KB
testcase_15 AC 73 ms
76,164 KB
testcase_16 AC 76 ms
76,200 KB
testcase_17 AC 72 ms
76,116 KB
testcase_18 TLE -
testcase_19 AC 1,990 ms
105,648 KB
testcase_20 AC 1,151 ms
100,536 KB
testcase_21 AC 256 ms
77,800 KB
testcase_22 AC 1,273 ms
98,160 KB
testcase_23 AC 203 ms
77,832 KB
testcase_24 AC 1,620 ms
105,140 KB
testcase_25 AC 1,222 ms
99,020 KB
testcase_26 AC 478 ms
85,072 KB
testcase_27 AC 205 ms
77,672 KB
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 65 ms
71,280 KB
testcase_44 AC 81 ms
76,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

def f(x):
    return sum(Bi*abs(x-Ai) for Ai, Bi in zip(A, B))

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
l, r = -10**18, 10**18

while r-l>=5:
    t1 = (2*l+r)//3
    t2 = (l+2*r)//3
    
    if f(t1)>f(t2):
        l = t1
    else:
        r = t2

v = [(f(x), x) for x in range(l, r+1)]
v.sort()
print(v[0][1], v[0][0])
0