結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー yuusanlondonyuusanlondon
提出日時 2020-10-09 21:37:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 454 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 557 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 131,916 KB
最終ジャッジ日時 2023-09-27 15:41:04
合計ジャッジ時間 25,018 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,108 KB
testcase_01 AC 71 ms
71,464 KB
testcase_02 AC 72 ms
71,308 KB
testcase_03 AC 73 ms
71,412 KB
testcase_04 AC 76 ms
71,476 KB
testcase_05 AC 74 ms
71,304 KB
testcase_06 AC 73 ms
71,508 KB
testcase_07 AC 72 ms
71,256 KB
testcase_08 AC 73 ms
71,412 KB
testcase_09 AC 73 ms
71,300 KB
testcase_10 AC 73 ms
71,336 KB
testcase_11 AC 75 ms
71,576 KB
testcase_12 AC 71 ms
71,216 KB
testcase_13 AC 72 ms
71,260 KB
testcase_14 AC 72 ms
71,484 KB
testcase_15 AC 71 ms
71,108 KB
testcase_16 AC 72 ms
71,456 KB
testcase_17 AC 73 ms
71,492 KB
testcase_18 AC 439 ms
131,072 KB
testcase_19 AC 424 ms
127,788 KB
testcase_20 AC 247 ms
103,160 KB
testcase_21 AC 106 ms
79,340 KB
testcase_22 AC 259 ms
104,896 KB
testcase_23 AC 96 ms
76,632 KB
testcase_24 AC 381 ms
131,916 KB
testcase_25 AC 253 ms
103,836 KB
testcase_26 AC 148 ms
90,976 KB
testcase_27 AC 97 ms
76,648 KB
testcase_28 AC 449 ms
129,020 KB
testcase_29 AC 433 ms
128,648 KB
testcase_30 AC 440 ms
128,752 KB
testcase_31 AC 431 ms
128,716 KB
testcase_32 AC 430 ms
129,100 KB
testcase_33 AC 438 ms
129,012 KB
testcase_34 AC 443 ms
129,120 KB
testcase_35 AC 436 ms
129,172 KB
testcase_36 AC 451 ms
128,656 KB
testcase_37 AC 444 ms
128,824 KB
testcase_38 AC 443 ms
129,016 KB
testcase_39 AC 444 ms
129,012 KB
testcase_40 AC 454 ms
128,992 KB
testcase_41 AC 448 ms
128,964 KB
testcase_42 AC 434 ms
128,908 KB
testcase_43 AC 73 ms
71,476 KB
testcase_44 AC 73 ms
71,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
nums=[]
for i in range(n):
  nums.append([a[i],b[i]])
nums=sorted(nums, key=lambda student: student[0])
bsum=sum(b)
curr=0
for i in range(n):
  curr+=nums[i][1]
  if curr*2>=bsum:
    point=i
    break
option1=point-1
option2=point
ans1=0
ans2=0
for i in range(n):
  ans1+=nums[i][1]*abs(nums[i][0]-nums[option1][0])
  ans2+=nums[i][1]*abs(nums[i][0]-nums[option2][0])
if ans1<ans2:
  print(nums[option1][0],ans1)
else:
  print(nums[option2][0],ans2)
  
0