結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー 👑 KazunKazun
提出日時 2020-08-14 19:06:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 87,200 KB
実行使用メモリ 125,568 KB
最終ジャッジ日時 2023-09-27 12:12:27
合計ジャッジ時間 23,295 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
71,532 KB
testcase_01 AC 57 ms
71,308 KB
testcase_02 AC 59 ms
71,344 KB
testcase_03 AC 60 ms
71,156 KB
testcase_04 AC 62 ms
71,576 KB
testcase_05 AC 58 ms
71,352 KB
testcase_06 AC 61 ms
71,404 KB
testcase_07 AC 60 ms
71,540 KB
testcase_08 AC 60 ms
71,560 KB
testcase_09 AC 60 ms
71,484 KB
testcase_10 AC 61 ms
71,420 KB
testcase_11 AC 59 ms
71,480 KB
testcase_12 AC 61 ms
71,564 KB
testcase_13 AC 62 ms
71,308 KB
testcase_14 AC 60 ms
71,156 KB
testcase_15 AC 60 ms
71,460 KB
testcase_16 AC 60 ms
71,544 KB
testcase_17 AC 62 ms
71,348 KB
testcase_18 AC 340 ms
125,568 KB
testcase_19 AC 329 ms
122,272 KB
testcase_20 AC 192 ms
101,804 KB
testcase_21 AC 78 ms
76,776 KB
testcase_22 AC 201 ms
100,128 KB
testcase_23 AC 79 ms
76,612 KB
testcase_24 AC 254 ms
104,268 KB
testcase_25 AC 197 ms
100,720 KB
testcase_26 AC 113 ms
86,924 KB
testcase_27 AC 75 ms
76,768 KB
testcase_28 AC 345 ms
124,628 KB
testcase_29 AC 352 ms
124,240 KB
testcase_30 AC 349 ms
124,596 KB
testcase_31 AC 345 ms
124,560 KB
testcase_32 AC 348 ms
124,840 KB
testcase_33 AC 352 ms
124,764 KB
testcase_34 AC 363 ms
124,772 KB
testcase_35 AC 354 ms
124,704 KB
testcase_36 AC 347 ms
124,276 KB
testcase_37 AC 359 ms
124,636 KB
testcase_38 AC 354 ms
124,476 KB
testcase_39 AC 353 ms
124,556 KB
testcase_40 AC 349 ms
124,752 KB
testcase_41 AC 355 ms
124,576 KB
testcase_42 AC 355 ms
124,744 KB
testcase_43 AC 60 ms
71,548 KB
testcase_44 AC 60 ms
71,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x):
    S=0
    for k in range(N):
        S+=B[k]*abs(x-A[k])
    return S

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
B_sum=sum(B)

L=[0]*N
for k in range(N):
    L[k]=(A[k],B[k])

L.sort(key=lambda x:x[0])

Med=(B_sum+1)//2
Count=0

for (X,Y) in L:
    Count+=Y
    if Med<=Count:
        break

print(X,f(X))

0