結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー 👑 tamatotamato
提出日時 2020-10-09 21:27:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,572 KB
実行使用メモリ 134,512 KB
最終ジャッジ日時 2023-09-27 14:31:43
合計ジャッジ時間 19,212 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,692 KB
testcase_01 AC 61 ms
71,796 KB
testcase_02 AC 60 ms
71,508 KB
testcase_03 AC 60 ms
71,768 KB
testcase_04 AC 62 ms
71,644 KB
testcase_05 AC 63 ms
71,368 KB
testcase_06 AC 61 ms
71,728 KB
testcase_07 AC 61 ms
71,548 KB
testcase_08 AC 62 ms
71,492 KB
testcase_09 AC 61 ms
71,820 KB
testcase_10 AC 59 ms
71,932 KB
testcase_11 AC 61 ms
71,828 KB
testcase_12 AC 62 ms
71,772 KB
testcase_13 AC 60 ms
71,512 KB
testcase_14 AC 61 ms
71,600 KB
testcase_15 AC 62 ms
71,936 KB
testcase_16 AC 60 ms
71,772 KB
testcase_17 AC 62 ms
71,516 KB
testcase_18 AC 315 ms
123,640 KB
testcase_19 AC 292 ms
118,472 KB
testcase_20 AC 213 ms
106,868 KB
testcase_21 AC 82 ms
77,024 KB
testcase_22 AC 202 ms
106,736 KB
testcase_23 AC 87 ms
77,036 KB
testcase_24 AC 252 ms
112,908 KB
testcase_25 AC 197 ms
106,700 KB
testcase_26 AC 115 ms
88,368 KB
testcase_27 AC 79 ms
76,956 KB
testcase_28 AC 331 ms
134,308 KB
testcase_29 AC 343 ms
134,012 KB
testcase_30 AC 331 ms
134,356 KB
testcase_31 AC 344 ms
133,924 KB
testcase_32 AC 332 ms
134,180 KB
testcase_33 AC 333 ms
133,744 KB
testcase_34 AC 334 ms
134,132 KB
testcase_35 AC 335 ms
134,112 KB
testcase_36 AC 334 ms
134,512 KB
testcase_37 AC 332 ms
134,240 KB
testcase_38 AC 357 ms
134,268 KB
testcase_39 AC 338 ms
134,356 KB
testcase_40 AC 332 ms
133,648 KB
testcase_41 AC 337 ms
133,984 KB
testcase_42 AC 331 ms
134,184 KB
testcase_43 AC 62 ms
71,504 KB
testcase_44 AC 62 ms
71,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

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

    AB = [(a, b) for a, b in zip(A, B)]
    AB.sort(key=lambda x: x[0])
    A = [ab[0] for ab in AB]
    B = [ab[1] for ab in AB]

    S = sum(B)
    s = 0
    for i, b in enumerate(B):
        s += b
        if s * 2 >= S:
            ii = i
            break
    x = A[ii]
    mi = 0
    for i in range(N):
        mi += B[i] * abs(x - A[i])
    print(x, mi)


if __name__ == '__main__':
    main()
0