結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
94,460 KB
testcase_01 AC 71 ms
94,528 KB
testcase_02 AC 68 ms
94,544 KB
testcase_03 AC 69 ms
94,556 KB
testcase_04 AC 74 ms
94,744 KB
testcase_05 AC 69 ms
94,592 KB
testcase_06 AC 68 ms
94,860 KB
testcase_07 AC 68 ms
94,608 KB
testcase_08 AC 70 ms
94,808 KB
testcase_09 AC 69 ms
94,696 KB
testcase_10 AC 68 ms
94,628 KB
testcase_11 AC 69 ms
94,676 KB
testcase_12 AC 70 ms
94,660 KB
testcase_13 AC 70 ms
94,652 KB
testcase_14 AC 69 ms
94,404 KB
testcase_15 AC 70 ms
94,408 KB
testcase_16 AC 72 ms
94,584 KB
testcase_17 AC 72 ms
94,796 KB
testcase_18 AC 211 ms
167,556 KB
testcase_19 AC 210 ms
162,996 KB
testcase_20 AC 149 ms
131,412 KB
testcase_21 AC 90 ms
100,692 KB
testcase_22 AC 153 ms
134,804 KB
testcase_23 AC 84 ms
100,372 KB
testcase_24 AC 187 ms
148,576 KB
testcase_25 AC 154 ms
134,116 KB
testcase_26 AC 104 ms
113,632 KB
testcase_27 AC 84 ms
100,284 KB
testcase_28 AC 223 ms
171,080 KB
testcase_29 AC 217 ms
170,752 KB
testcase_30 AC 218 ms
170,816 KB
testcase_31 AC 217 ms
170,588 KB
testcase_32 AC 214 ms
171,040 KB
testcase_33 AC 217 ms
170,740 KB
testcase_34 AC 216 ms
171,376 KB
testcase_35 AC 217 ms
170,932 KB
testcase_36 AC 213 ms
171,120 KB
testcase_37 AC 216 ms
171,236 KB
testcase_38 AC 218 ms
171,000 KB
testcase_39 AC 213 ms
170,856 KB
testcase_40 AC 212 ms
170,624 KB
testcase_41 AC 210 ms
170,512 KB
testcase_42 AC 214 ms
170,896 KB
testcase_43 AC 71 ms
94,624 KB
testcase_44 AC 69 ms
94,564 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