結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー kohei2019kohei2019
提出日時 2022-07-19 21:39:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 506 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 110,316 KB
最終ジャッジ日時 2023-09-14 18:29:43
合計ジャッジ時間 23,852 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,176 KB
testcase_01 AC 71 ms
71,016 KB
testcase_02 AC 72 ms
71,296 KB
testcase_03 AC 71 ms
71,348 KB
testcase_04 AC 72 ms
71,032 KB
testcase_05 AC 72 ms
71,376 KB
testcase_06 AC 71 ms
71,436 KB
testcase_07 AC 70 ms
71,348 KB
testcase_08 AC 77 ms
75,592 KB
testcase_09 AC 76 ms
75,372 KB
testcase_10 AC 75 ms
75,304 KB
testcase_11 AC 74 ms
75,380 KB
testcase_12 AC 76 ms
75,492 KB
testcase_13 AC 75 ms
75,352 KB
testcase_14 AC 78 ms
75,440 KB
testcase_15 AC 76 ms
75,400 KB
testcase_16 AC 76 ms
75,572 KB
testcase_17 AC 77 ms
75,716 KB
testcase_18 AC 310 ms
109,640 KB
testcase_19 AC 290 ms
106,048 KB
testcase_20 AC 207 ms
101,608 KB
testcase_21 AC 94 ms
75,896 KB
testcase_22 AC 212 ms
99,760 KB
testcase_23 AC 90 ms
75,908 KB
testcase_24 AC 258 ms
102,884 KB
testcase_25 AC 208 ms
100,468 KB
testcase_26 AC 123 ms
84,124 KB
testcase_27 AC 92 ms
76,204 KB
testcase_28 AC 319 ms
110,316 KB
testcase_29 AC 311 ms
109,960 KB
testcase_30 AC 317 ms
110,180 KB
testcase_31 AC 321 ms
110,224 KB
testcase_32 AC 314 ms
110,040 KB
testcase_33 AC 315 ms
110,124 KB
testcase_34 AC 320 ms
110,172 KB
testcase_35 AC 319 ms
109,956 KB
testcase_36 AC 316 ms
109,912 KB
testcase_37 AC 311 ms
110,308 KB
testcase_38 AC 315 ms
110,196 KB
testcase_39 AC 317 ms
110,092 KB
testcase_40 AC 319 ms
109,928 KB
testcase_41 AC 321 ms
109,832 KB
testcase_42 AC 316 ms
110,148 KB
testcase_43 AC 71 ms
71,020 KB
testcase_44 AC 71 ms
71,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
lsA = list(map(int,input().split()))
lsB = list(map(int,input().split()))

def func(arg):
    a = 0
    for i in range(N):
        a += lsB[i] * abs(arg-lsA[i])
    return a

def sanbunntan(l,r):
    while l + 2 < r:
        c1 = l+(r-l)//3
        c2 = r-(r-l)//3
        if func(c1)<func(c2):
            r = c2
        else:
            l = c1
    val = sorted([(func(i),i) for i in range(l,r+1)])[0][1]
    return val

ans = sanbunntan(-10**6, 10**6+1)
fans = func(ans)
print(ans,fans)
0