結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー taiga000629taiga000629
提出日時 2020-10-09 23:36:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 394 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 171,368 KB
最終ジャッジ日時 2023-09-27 19:57:55
合計ジャッジ時間 18,341 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
94,704 KB
testcase_01 AC 74 ms
94,796 KB
testcase_02 AC 74 ms
94,552 KB
testcase_03 AC 73 ms
94,524 KB
testcase_04 AC 74 ms
94,388 KB
testcase_05 AC 75 ms
94,748 KB
testcase_06 AC 74 ms
94,624 KB
testcase_07 AC 75 ms
94,656 KB
testcase_08 AC 74 ms
94,800 KB
testcase_09 AC 72 ms
94,656 KB
testcase_10 AC 75 ms
94,732 KB
testcase_11 AC 76 ms
94,564 KB
testcase_12 AC 75 ms
94,540 KB
testcase_13 AC 76 ms
94,728 KB
testcase_14 AC 76 ms
94,844 KB
testcase_15 AC 75 ms
94,472 KB
testcase_16 AC 76 ms
94,564 KB
testcase_17 AC 76 ms
94,704 KB
testcase_18 AC 226 ms
167,180 KB
testcase_19 AC 218 ms
163,060 KB
testcase_20 AC 162 ms
131,368 KB
testcase_21 AC 91 ms
101,008 KB
testcase_22 AC 159 ms
134,744 KB
testcase_23 AC 87 ms
100,540 KB
testcase_24 AC 186 ms
148,744 KB
testcase_25 AC 158 ms
134,276 KB
testcase_26 AC 107 ms
113,396 KB
testcase_27 AC 89 ms
100,364 KB
testcase_28 AC 218 ms
170,872 KB
testcase_29 AC 225 ms
170,904 KB
testcase_30 AC 220 ms
170,912 KB
testcase_31 AC 222 ms
170,776 KB
testcase_32 AC 215 ms
171,144 KB
testcase_33 AC 221 ms
170,904 KB
testcase_34 AC 223 ms
171,048 KB
testcase_35 AC 219 ms
171,008 KB
testcase_36 AC 220 ms
171,368 KB
testcase_37 AC 224 ms
171,256 KB
testcase_38 AC 217 ms
170,848 KB
testcase_39 AC 223 ms
171,124 KB
testcase_40 AC 226 ms
170,688 KB
testcase_41 AC 220 ms
170,700 KB
testcase_42 AC 222 ms
170,844 KB
testcase_43 AC 75 ms
94,844 KB
testcase_44 AC 75 ms
94,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=[0]*(3000000)
sumb=sum(b)
A=[a[i] for i in range(n)]
def f(x):
    global n
    res=0
    for i in range(n):
        res+=b[i]*abs(x-A[i])
    return res

for i in range(n):
    ans[a[i]]+=b[i]
a.sort()
a=list(set(a))
num=0
for x in a:
    num+=ans[x]
    if num*2>=sumb:
        print(x,f(x))
        exit()
0