結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,236 KB
testcase_01 AC 68 ms
71,444 KB
testcase_02 AC 68 ms
71,496 KB
testcase_03 AC 68 ms
71,404 KB
testcase_04 AC 69 ms
71,508 KB
testcase_05 AC 68 ms
71,448 KB
testcase_06 AC 70 ms
71,364 KB
testcase_07 AC 69 ms
71,768 KB
testcase_08 AC 68 ms
71,404 KB
testcase_09 AC 69 ms
71,456 KB
testcase_10 AC 68 ms
71,444 KB
testcase_11 AC 70 ms
71,744 KB
testcase_12 AC 70 ms
71,396 KB
testcase_13 AC 69 ms
71,596 KB
testcase_14 AC 68 ms
71,332 KB
testcase_15 AC 69 ms
71,232 KB
testcase_16 AC 69 ms
71,496 KB
testcase_17 AC 67 ms
71,376 KB
testcase_18 AC 591 ms
128,680 KB
testcase_19 AC 561 ms
123,000 KB
testcase_20 AC 339 ms
101,652 KB
testcase_21 AC 106 ms
78,252 KB
testcase_22 AC 370 ms
104,320 KB
testcase_23 AC 99 ms
77,956 KB
testcase_24 AC 473 ms
120,404 KB
testcase_25 AC 358 ms
103,336 KB
testcase_26 AC 165 ms
87,632 KB
testcase_27 AC 98 ms
77,600 KB
testcase_28 AC 608 ms
129,136 KB
testcase_29 AC 613 ms
128,832 KB
testcase_30 AC 613 ms
128,956 KB
testcase_31 AC 616 ms
129,324 KB
testcase_32 AC 628 ms
129,400 KB
testcase_33 AC 609 ms
129,332 KB
testcase_34 AC 623 ms
129,296 KB
testcase_35 AC 607 ms
129,340 KB
testcase_36 AC 610 ms
129,048 KB
testcase_37 AC 613 ms
129,588 KB
testcase_38 AC 616 ms
129,328 KB
testcase_39 AC 607 ms
129,064 KB
testcase_40 AC 610 ms
129,320 KB
testcase_41 AC 603 ms
128,868 KB
testcase_42 AC 620 ms
129,440 KB
testcase_43 AC 69 ms
71,448 KB
testcase_44 AC 69 ms
71,240 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 = []
  ran = list(range(n))
  for i in ran:
    L.append((A[i], B[i]))
  L.sort()
  now, f = 0, 0
  s = math.floor((sum(B)+1)/2)
  for i in L:
    k, v = i
    now += v
    if now >= s:
      x = k
      break
  for i in ran:
    f += B[i]*abs(x-A[i])
  print(x, f)
main()
0