結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー 👑 rin204rin204
提出日時 2022-01-18 21:37:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 589 ms / 2,000 ms
コード長 308 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 127,992 KB
最終ジャッジ日時 2024-05-02 19:32:11
合計ジャッジ時間 23,825 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,840 KB
testcase_01 AC 35 ms
51,584 KB
testcase_02 AC 36 ms
52,096 KB
testcase_03 AC 36 ms
51,584 KB
testcase_04 AC 33 ms
51,712 KB
testcase_05 AC 35 ms
51,456 KB
testcase_06 AC 35 ms
51,712 KB
testcase_07 AC 34 ms
52,224 KB
testcase_08 AC 33 ms
51,712 KB
testcase_09 AC 33 ms
51,840 KB
testcase_10 AC 33 ms
51,456 KB
testcase_11 AC 32 ms
51,712 KB
testcase_12 AC 35 ms
51,712 KB
testcase_13 AC 35 ms
51,840 KB
testcase_14 AC 37 ms
52,096 KB
testcase_15 AC 33 ms
51,712 KB
testcase_16 AC 35 ms
51,712 KB
testcase_17 AC 35 ms
51,968 KB
testcase_18 AC 552 ms
127,168 KB
testcase_19 AC 528 ms
121,580 KB
testcase_20 AC 310 ms
103,168 KB
testcase_21 AC 83 ms
76,032 KB
testcase_22 AC 368 ms
104,064 KB
testcase_23 AC 77 ms
76,416 KB
testcase_24 AC 440 ms
117,008 KB
testcase_25 AC 321 ms
103,552 KB
testcase_26 AC 140 ms
86,400 KB
testcase_27 AC 83 ms
76,160 KB
testcase_28 AC 585 ms
127,608 KB
testcase_29 AC 581 ms
127,692 KB
testcase_30 AC 571 ms
127,220 KB
testcase_31 AC 570 ms
127,568 KB
testcase_32 AC 582 ms
127,396 KB
testcase_33 AC 578 ms
127,600 KB
testcase_34 AC 576 ms
127,740 KB
testcase_35 AC 572 ms
127,992 KB
testcase_36 AC 575 ms
127,564 KB
testcase_37 AC 578 ms
127,600 KB
testcase_38 AC 589 ms
127,352 KB
testcase_39 AC 577 ms
127,480 KB
testcase_40 AC 574 ms
127,732 KB
testcase_41 AC 572 ms
127,608 KB
testcase_42 AC 576 ms
127,616 KB
testcase_43 AC 36 ms
51,712 KB
testcase_44 AC 34 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
tot = sum(B)
ab = [(a, b) for a, b in zip(A, B)]
ab.sort()
cnt = 0
for a, b in ab:
    cnt += b
    if cnt * 2 >= tot:
        x = a
        break

ans = 0
for a, b in zip(A, B):
    ans += b * abs(x - a)
print(x, ans)
0