結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー NatsubiSoganNatsubiSogan
提出日時 2020-10-17 15:19:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 505 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 39,416 KB
最終ジャッジ日時 2023-09-28 08:12:33
合計ジャッジ時間 20,900 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,808 KB
testcase_01 AC 15 ms
7,900 KB
testcase_02 AC 14 ms
7,860 KB
testcase_03 AC 14 ms
7,860 KB
testcase_04 AC 14 ms
7,820 KB
testcase_05 AC 14 ms
7,800 KB
testcase_06 AC 13 ms
7,856 KB
testcase_07 AC 14 ms
7,920 KB
testcase_08 AC 14 ms
7,788 KB
testcase_09 AC 14 ms
7,908 KB
testcase_10 AC 13 ms
7,800 KB
testcase_11 AC 14 ms
7,852 KB
testcase_12 AC 13 ms
7,824 KB
testcase_13 AC 13 ms
7,944 KB
testcase_14 AC 14 ms
7,812 KB
testcase_15 AC 14 ms
7,804 KB
testcase_16 AC 15 ms
7,812 KB
testcase_17 AC 14 ms
7,796 KB
testcase_18 AC 425 ms
37,980 KB
testcase_19 AC 435 ms
37,764 KB
testcase_20 AC 236 ms
24,488 KB
testcase_21 AC 39 ms
10,564 KB
testcase_22 AC 259 ms
25,996 KB
testcase_23 AC 31 ms
10,400 KB
testcase_24 AC 382 ms
31,488 KB
testcase_25 AC 251 ms
25,208 KB
testcase_26 AC 79 ms
14,396 KB
testcase_27 AC 32 ms
10,352 KB
testcase_28 AC 505 ms
39,296 KB
testcase_29 AC 495 ms
39,384 KB
testcase_30 AC 495 ms
39,320 KB
testcase_31 AC 498 ms
39,364 KB
testcase_32 AC 500 ms
39,212 KB
testcase_33 AC 503 ms
39,416 KB
testcase_34 AC 502 ms
39,072 KB
testcase_35 AC 430 ms
39,292 KB
testcase_36 AC 446 ms
39,212 KB
testcase_37 AC 434 ms
39,416 KB
testcase_38 AC 434 ms
39,356 KB
testcase_39 AC 440 ms
39,380 KB
testcase_40 AC 435 ms
39,376 KB
testcase_41 AC 457 ms
39,416 KB
testcase_42 AC 434 ms
39,224 KB
testcase_43 AC 13 ms
7,780 KB
testcase_44 AC 14 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = sum(b)
l = [(a[i], b[i]) for i in range(n)]
l.sort()
cnt = 0
ind = float("inf")
for i in range(n):
    cnt += l[i][1]
    if cnt >= s - cnt:
        ind = i
        break
ans = 0
for i in range(n):
    ans += l[i][1] * abs(l[ind][0] - l[i][0])
print(l[ind][0], ans)
0