結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー raven7959raven7959
提出日時 2021-08-22 11:09:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 736 ms / 2,000 ms
コード長 385 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 132,824 KB
最終ジャッジ日時 2024-04-24 00:50:59
合計ジャッジ時間 27,187 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,684 KB
testcase_01 AC 39 ms
53,444 KB
testcase_02 AC 39 ms
53,360 KB
testcase_03 AC 37 ms
52,952 KB
testcase_04 AC 39 ms
52,636 KB
testcase_05 AC 40 ms
52,492 KB
testcase_06 AC 40 ms
54,216 KB
testcase_07 AC 41 ms
53,240 KB
testcase_08 AC 40 ms
53,520 KB
testcase_09 AC 39 ms
53,368 KB
testcase_10 AC 39 ms
53,348 KB
testcase_11 AC 40 ms
53,948 KB
testcase_12 AC 40 ms
53,572 KB
testcase_13 AC 41 ms
52,792 KB
testcase_14 AC 40 ms
53,756 KB
testcase_15 AC 40 ms
52,808 KB
testcase_16 AC 40 ms
53,552 KB
testcase_17 AC 40 ms
53,640 KB
testcase_18 AC 725 ms
132,824 KB
testcase_19 AC 736 ms
129,800 KB
testcase_20 AC 354 ms
105,088 KB
testcase_21 AC 86 ms
78,036 KB
testcase_22 AC 401 ms
107,352 KB
testcase_23 AC 71 ms
74,096 KB
testcase_24 AC 596 ms
128,156 KB
testcase_25 AC 393 ms
105,444 KB
testcase_26 AC 157 ms
89,776 KB
testcase_27 AC 79 ms
77,584 KB
testcase_28 AC 697 ms
130,936 KB
testcase_29 AC 726 ms
130,520 KB
testcase_30 AC 732 ms
130,700 KB
testcase_31 AC 734 ms
130,404 KB
testcase_32 AC 720 ms
130,948 KB
testcase_33 AC 719 ms
130,672 KB
testcase_34 AC 718 ms
130,956 KB
testcase_35 AC 736 ms
130,676 KB
testcase_36 AC 705 ms
130,672 KB
testcase_37 AC 695 ms
130,944 KB
testcase_38 AC 692 ms
130,696 KB
testcase_39 AC 710 ms
131,080 KB
testcase_40 AC 692 ms
130,956 KB
testcase_41 AC 698 ms
130,428 KB
testcase_42 AC 716 ms
131,080 KB
testcase_43 AC 40 ms
52,756 KB
testcase_44 AC 40 ms
53,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate
from bisect import bisect_left
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Q=[]
for i in range(N):
  Q.append([A[i],B[i]])
Q=sorted(Q)
QB=[Q[i][1] for i in range(N)]
BA=list(accumulate(QB))
num=(BA[-1]+1)//2
idx=bisect_left(BA,num)
ans=0
for i in range(N):
  ans+=Q[i][1]*abs(Q[idx][0]-Q[i][0])
print(Q[idx][0],ans)
0