結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー mesame3993mesame3993
提出日時 2021-11-19 01:04:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 127,992 KB
最終ジャッジ日時 2023-08-27 20:15:41
合計ジャッジ時間 26,794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,196 KB
testcase_01 AC 68 ms
71,100 KB
testcase_02 AC 70 ms
71,004 KB
testcase_03 AC 69 ms
71,284 KB
testcase_04 AC 70 ms
71,000 KB
testcase_05 AC 69 ms
71,152 KB
testcase_06 AC 67 ms
71,084 KB
testcase_07 AC 68 ms
71,264 KB
testcase_08 AC 69 ms
71,304 KB
testcase_09 AC 69 ms
71,416 KB
testcase_10 AC 69 ms
71,204 KB
testcase_11 AC 70 ms
71,416 KB
testcase_12 AC 70 ms
71,400 KB
testcase_13 AC 69 ms
71,324 KB
testcase_14 AC 69 ms
71,452 KB
testcase_15 AC 69 ms
71,208 KB
testcase_16 AC 69 ms
71,396 KB
testcase_17 AC 67 ms
71,396 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 343 ms
100,880 KB
testcase_21 AC 105 ms
77,804 KB
testcase_22 WA -
testcase_23 AC 103 ms
77,456 KB
testcase_24 AC 464 ms
118,992 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 99 ms
77,620 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 69 ms
71,364 KB
testcase_44 AC 69 ms
71,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
  from sys import stdin
  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 range(n):
    k, v = L[i]
    now += v
    if now >= su//2-1:
      x0 = k
    if now >= su//2:
      x1 = k
      break
    else:
      x1 = L[i+1][0]
  if n % 2 == 0:
    x = (x0 + x1) / 2
  else:
    x = x0
  f = 0
  for i in range(n):
    f += B[i] * abs(x-A[i])
  print(x, int(f))
main()
0