結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-23 20:32:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 495 ms / 2,000 ms
コード長 274 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 10,684 KB
実行使用メモリ 40,568 KB
最終ジャッジ日時 2023-09-17 11:19:30
合計ジャッジ時間 22,811 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,868 KB
testcase_01 AC 17 ms
7,868 KB
testcase_02 AC 16 ms
7,872 KB
testcase_03 AC 15 ms
7,980 KB
testcase_04 AC 16 ms
7,936 KB
testcase_05 AC 16 ms
7,928 KB
testcase_06 AC 16 ms
7,916 KB
testcase_07 AC 16 ms
7,868 KB
testcase_08 AC 17 ms
7,940 KB
testcase_09 AC 16 ms
7,984 KB
testcase_10 AC 16 ms
7,952 KB
testcase_11 AC 16 ms
7,968 KB
testcase_12 AC 16 ms
7,880 KB
testcase_13 AC 16 ms
7,996 KB
testcase_14 AC 16 ms
8,008 KB
testcase_15 AC 16 ms
7,924 KB
testcase_16 AC 17 ms
7,928 KB
testcase_17 AC 16 ms
7,952 KB
testcase_18 AC 461 ms
39,028 KB
testcase_19 AC 450 ms
37,796 KB
testcase_20 AC 251 ms
24,564 KB
testcase_21 AC 38 ms
10,552 KB
testcase_22 AC 264 ms
26,008 KB
testcase_23 AC 31 ms
10,404 KB
testcase_24 AC 357 ms
32,628 KB
testcase_25 AC 242 ms
25,288 KB
testcase_26 AC 73 ms
14,076 KB
testcase_27 AC 32 ms
10,412 KB
testcase_28 AC 474 ms
39,264 KB
testcase_29 AC 472 ms
39,272 KB
testcase_30 AC 476 ms
39,264 KB
testcase_31 AC 458 ms
39,316 KB
testcase_32 AC 484 ms
39,348 KB
testcase_33 AC 481 ms
39,188 KB
testcase_34 AC 474 ms
39,320 KB
testcase_35 AC 471 ms
40,568 KB
testcase_36 AC 452 ms
38,956 KB
testcase_37 AC 476 ms
39,364 KB
testcase_38 AC 473 ms
39,320 KB
testcase_39 AC 474 ms
39,372 KB
testcase_40 AC 491 ms
39,352 KB
testcase_41 AC 495 ms
39,324 KB
testcase_42 AC 486 ms
39,268 KB
testcase_43 AC 16 ms
7,948 KB
testcase_44 AC 16 ms
7,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

m = (sum(B) + 1)//2
AB = sorted(zip(A, B))

for a, b in AB:
    m -= b
    if m <= 0:
        i = a
        break

ans = sum(b * abs(i - a) for a, b in AB)
print(i, ans)
0