結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,280 KB
testcase_01 AC 69 ms
71,340 KB
testcase_02 AC 68 ms
71,352 KB
testcase_03 AC 68 ms
71,224 KB
testcase_04 AC 70 ms
71,176 KB
testcase_05 AC 69 ms
71,248 KB
testcase_06 AC 68 ms
71,212 KB
testcase_07 AC 68 ms
71,072 KB
testcase_08 AC 68 ms
71,180 KB
testcase_09 AC 69 ms
71,048 KB
testcase_10 AC 68 ms
71,336 KB
testcase_11 AC 69 ms
71,024 KB
testcase_12 AC 69 ms
71,468 KB
testcase_13 AC 67 ms
71,220 KB
testcase_14 AC 69 ms
71,300 KB
testcase_15 AC 68 ms
71,280 KB
testcase_16 AC 68 ms
71,220 KB
testcase_17 AC 71 ms
71,344 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 342 ms
100,840 KB
testcase_21 AC 105 ms
77,628 KB
testcase_22 WA -
testcase_23 AC 99 ms
77,404 KB
testcase_24 AC 470 ms
118,968 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 98 ms
77,476 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 70 ms
71,376 KB
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

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]
      break
  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