結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー mesame3993mesame3993
提出日時 2021-11-19 01:11:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 624 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 128,196 KB
最終ジャッジ日時 2023-08-27 20:26:47
合計ジャッジ時間 26,108 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,352 KB
testcase_01 AC 67 ms
71,692 KB
testcase_02 AC 68 ms
71,324 KB
testcase_03 AC 69 ms
71,404 KB
testcase_04 AC 69 ms
71,220 KB
testcase_05 AC 73 ms
71,496 KB
testcase_06 AC 72 ms
71,444 KB
testcase_07 AC 70 ms
71,420 KB
testcase_08 AC 69 ms
71,240 KB
testcase_09 AC 69 ms
71,492 KB
testcase_10 AC 70 ms
71,496 KB
testcase_11 AC 69 ms
71,416 KB
testcase_12 AC 69 ms
71,364 KB
testcase_13 AC 67 ms
71,364 KB
testcase_14 AC 71 ms
71,728 KB
testcase_15 AC 70 ms
71,328 KB
testcase_16 AC 72 ms
71,496 KB
testcase_17 AC 72 ms
71,364 KB
testcase_18 AC 594 ms
127,520 KB
testcase_19 AC 567 ms
121,892 KB
testcase_20 AC 342 ms
101,252 KB
testcase_21 AC 107 ms
78,092 KB
testcase_22 AC 369 ms
103,880 KB
testcase_23 AC 99 ms
78,036 KB
testcase_24 AC 471 ms
119,620 KB
testcase_25 AC 353 ms
102,912 KB
testcase_26 AC 165 ms
87,744 KB
testcase_27 AC 98 ms
78,112 KB
testcase_28 AC 608 ms
128,196 KB
testcase_29 AC 619 ms
127,692 KB
testcase_30 AC 612 ms
127,784 KB
testcase_31 AC 608 ms
127,916 KB
testcase_32 AC 624 ms
127,904 KB
testcase_33 AC 615 ms
128,032 KB
testcase_34 AC 608 ms
127,836 KB
testcase_35 AC 612 ms
127,848 KB
testcase_36 AC 610 ms
127,780 KB
testcase_37 AC 608 ms
127,924 KB
testcase_38 AC 608 ms
127,916 KB
testcase_39 AC 611 ms
127,840 KB
testcase_40 AC 606 ms
127,836 KB
testcase_41 AC 613 ms
127,828 KB
testcase_42 AC 616 ms
127,956 KB
testcase_43 AC 68 ms
71,740 KB
testcase_44 AC 68 ms
71,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  from sys import stdin
  import math
  readline=stdin.readline
  n = int(readline())
  A = list(map(int, readline().split()))
  B = list(map(int, readline().split()))
  L = list()
  for i in range(n):
    L.append((A[i], B[i]))
  L.sort()
  now = 0
  su = sum(B)
  for i in L:
    k, v = i
    now += v
    if now >= math.floor((su+1) / 2):
      x = k
      break
  f = 0
  for i in range(n):
    f += B[i] * abs(x-A[i])
  print(x, f)
main()
0