結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー hir355hir355
提出日時 2020-10-09 21:39:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 668 ms / 2,000 ms
コード長 304 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 129,352 KB
最終ジャッジ日時 2023-09-27 15:46:53
合計ジャッジ時間 27,039 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,608 KB
testcase_01 AC 70 ms
71,272 KB
testcase_02 AC 71 ms
71,300 KB
testcase_03 AC 71 ms
71,412 KB
testcase_04 AC 70 ms
71,276 KB
testcase_05 AC 69 ms
71,236 KB
testcase_06 AC 69 ms
71,312 KB
testcase_07 AC 70 ms
71,276 KB
testcase_08 AC 70 ms
71,248 KB
testcase_09 AC 70 ms
71,224 KB
testcase_10 AC 70 ms
71,480 KB
testcase_11 AC 70 ms
71,464 KB
testcase_12 AC 69 ms
71,564 KB
testcase_13 AC 73 ms
71,480 KB
testcase_14 AC 71 ms
71,376 KB
testcase_15 AC 71 ms
71,224 KB
testcase_16 AC 69 ms
71,356 KB
testcase_17 AC 71 ms
71,552 KB
testcase_18 AC 637 ms
128,984 KB
testcase_19 AC 608 ms
122,788 KB
testcase_20 AC 360 ms
102,084 KB
testcase_21 AC 112 ms
78,836 KB
testcase_22 AC 388 ms
103,400 KB
testcase_23 AC 100 ms
77,572 KB
testcase_24 AC 510 ms
119,144 KB
testcase_25 AC 371 ms
102,340 KB
testcase_26 AC 179 ms
88,456 KB
testcase_27 AC 101 ms
77,704 KB
testcase_28 AC 654 ms
129,352 KB
testcase_29 AC 657 ms
128,860 KB
testcase_30 AC 660 ms
128,944 KB
testcase_31 AC 656 ms
129,096 KB
testcase_32 AC 661 ms
129,188 KB
testcase_33 AC 658 ms
129,148 KB
testcase_34 AC 654 ms
128,916 KB
testcase_35 AC 655 ms
129,072 KB
testcase_36 AC 652 ms
128,864 KB
testcase_37 AC 666 ms
129,020 KB
testcase_38 AC 666 ms
129,156 KB
testcase_39 AC 659 ms
128,980 KB
testcase_40 AC 668 ms
129,096 KB
testcase_41 AC 658 ms
128,916 KB
testcase_42 AC 665 ms
129,096 KB
testcase_43 AC 71 ms
71,364 KB
testcase_44 AC 71 ms
71,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a, b = zip(*sorted(zip(a, b)))
s = sum(b)
t = 0
for i in range(n):
    t += b[i]
    if t >= s // 2 + 1:
        res = a[i]
        break
ans = 0
for i in range(n):
    ans += abs(a[i] - res) * b[i]
print(res, ans)
0