結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー tikitaka1201tikitaka1201
提出日時 2020-10-16 10:42:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 661 ms / 2,000 ms
コード長 322 bytes
コンパイル時間 1,262 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 149,972 KB
最終ジャッジ日時 2023-09-28 01:47:29
合計ジャッジ時間 29,015 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
70,712 KB
testcase_01 AC 70 ms
70,744 KB
testcase_02 AC 68 ms
70,856 KB
testcase_03 AC 69 ms
70,748 KB
testcase_04 AC 68 ms
70,540 KB
testcase_05 AC 70 ms
70,848 KB
testcase_06 AC 69 ms
70,880 KB
testcase_07 AC 68 ms
70,740 KB
testcase_08 AC 69 ms
70,732 KB
testcase_09 AC 68 ms
70,744 KB
testcase_10 AC 67 ms
70,588 KB
testcase_11 AC 69 ms
70,580 KB
testcase_12 AC 70 ms
70,588 KB
testcase_13 AC 68 ms
70,856 KB
testcase_14 AC 67 ms
70,724 KB
testcase_15 AC 70 ms
70,624 KB
testcase_16 AC 73 ms
70,744 KB
testcase_17 AC 69 ms
70,592 KB
testcase_18 AC 655 ms
149,972 KB
testcase_19 AC 599 ms
145,240 KB
testcase_20 AC 363 ms
107,064 KB
testcase_21 AC 109 ms
77,712 KB
testcase_22 AC 387 ms
109,192 KB
testcase_23 AC 100 ms
77,064 KB
testcase_24 AC 492 ms
120,796 KB
testcase_25 AC 372 ms
109,052 KB
testcase_26 AC 172 ms
89,268 KB
testcase_27 AC 102 ms
76,976 KB
testcase_28 AC 657 ms
147,992 KB
testcase_29 AC 657 ms
148,124 KB
testcase_30 AC 649 ms
148,068 KB
testcase_31 AC 654 ms
147,892 KB
testcase_32 AC 653 ms
148,156 KB
testcase_33 AC 652 ms
148,172 KB
testcase_34 AC 648 ms
148,088 KB
testcase_35 AC 661 ms
148,500 KB
testcase_36 AC 656 ms
147,888 KB
testcase_37 AC 656 ms
147,976 KB
testcase_38 AC 648 ms
148,288 KB
testcase_39 AC 649 ms
148,152 KB
testcase_40 AC 652 ms
148,204 KB
testcase_41 AC 648 ms
148,056 KB
testcase_42 AC 657 ms
148,012 KB
testcase_43 AC 68 ms
70,996 KB
testcase_44 AC 68 ms
71,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())
sumb=sum(b)
l=[]
for i in range(n):
    l.append((a[i],b[i]))
l=sorted(l)
tmp=0
for i in range(n):
    tmp+=l[i][1]
    if tmp>=(sumb+1)//2:
        ind=i
        break

ai=l[ind][0]
ans=0
for i in range(n):
    ans+=b[i]*abs(ai-a[i])

print(ai,ans)
0