結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー tonyu0tonyu0
提出日時 2020-10-10 00:35:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 529 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 40,832 KB
最終ジャッジ日時 2023-09-27 20:28:52
合計ジャッジ時間 22,806 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,168 KB
testcase_01 AC 15 ms
8,048 KB
testcase_02 AC 16 ms
8,164 KB
testcase_03 AC 15 ms
8,020 KB
testcase_04 AC 15 ms
8,084 KB
testcase_05 AC 14 ms
8,132 KB
testcase_06 AC 16 ms
8,020 KB
testcase_07 AC 15 ms
8,216 KB
testcase_08 AC 16 ms
8,032 KB
testcase_09 AC 15 ms
8,024 KB
testcase_10 AC 15 ms
8,220 KB
testcase_11 AC 15 ms
8,068 KB
testcase_12 AC 15 ms
8,224 KB
testcase_13 AC 15 ms
8,020 KB
testcase_14 AC 15 ms
8,172 KB
testcase_15 AC 14 ms
8,252 KB
testcase_16 AC 15 ms
8,136 KB
testcase_17 AC 15 ms
8,176 KB
testcase_18 AC 494 ms
38,004 KB
testcase_19 AC 481 ms
37,700 KB
testcase_20 AC 256 ms
24,408 KB
testcase_21 AC 39 ms
10,552 KB
testcase_22 AC 273 ms
25,844 KB
testcase_23 AC 33 ms
10,464 KB
testcase_24 AC 376 ms
31,660 KB
testcase_25 AC 263 ms
25,324 KB
testcase_26 AC 86 ms
14,120 KB
testcase_27 AC 33 ms
10,404 KB
testcase_28 AC 514 ms
40,700 KB
testcase_29 AC 529 ms
40,492 KB
testcase_30 AC 508 ms
40,788 KB
testcase_31 AC 507 ms
40,752 KB
testcase_32 AC 504 ms
40,676 KB
testcase_33 AC 511 ms
40,640 KB
testcase_34 AC 517 ms
40,676 KB
testcase_35 AC 517 ms
40,660 KB
testcase_36 AC 504 ms
40,508 KB
testcase_37 AC 515 ms
40,804 KB
testcase_38 AC 501 ms
40,684 KB
testcase_39 AC 492 ms
40,708 KB
testcase_40 AC 502 ms
40,720 KB
testcase_41 AC 507 ms
40,832 KB
testcase_42 AC 502 ms
40,488 KB
testcase_43 AC 15 ms
8,164 KB
testcase_44 AC 15 ms
8,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
s = sum(B)
ab = []
for i in range(n):
    ab.append((A[i], B[i]))
ab.sort()
# med番目が中央値
med = (s + 1) // 2
now = 0
for i in range(n):
    now += ab[i][1]
    if now >= med:
        x = ab[i][0]
        y = sum(b * abs(a - x) for a, b in ab)
        print(x, y)
        exit()
0