結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー rlangevinrlangevin
提出日時 2023-01-28 01:09:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 666 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 129,168 KB
最終ジャッジ日時 2023-09-10 18:24:34
合計ジャッジ時間 30,796 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,356 KB
testcase_01 AC 74 ms
71,100 KB
testcase_02 AC 75 ms
71,348 KB
testcase_03 AC 75 ms
71,068 KB
testcase_04 AC 74 ms
71,212 KB
testcase_05 AC 75 ms
71,256 KB
testcase_06 AC 74 ms
71,036 KB
testcase_07 AC 75 ms
71,200 KB
testcase_08 AC 74 ms
71,532 KB
testcase_09 AC 76 ms
71,236 KB
testcase_10 AC 74 ms
71,344 KB
testcase_11 AC 73 ms
71,348 KB
testcase_12 AC 73 ms
71,240 KB
testcase_13 AC 75 ms
71,036 KB
testcase_14 AC 74 ms
71,240 KB
testcase_15 AC 74 ms
71,236 KB
testcase_16 AC 72 ms
71,288 KB
testcase_17 AC 76 ms
71,240 KB
testcase_18 AC 659 ms
128,516 KB
testcase_19 AC 610 ms
122,756 KB
testcase_20 AC 373 ms
101,884 KB
testcase_21 AC 119 ms
78,452 KB
testcase_22 AC 403 ms
103,576 KB
testcase_23 AC 107 ms
77,608 KB
testcase_24 AC 502 ms
119,080 KB
testcase_25 AC 381 ms
102,736 KB
testcase_26 AC 177 ms
87,920 KB
testcase_27 AC 106 ms
77,936 KB
testcase_28 AC 656 ms
128,832 KB
testcase_29 AC 656 ms
128,636 KB
testcase_30 AC 660 ms
128,992 KB
testcase_31 AC 664 ms
128,864 KB
testcase_32 AC 656 ms
129,016 KB
testcase_33 AC 666 ms
129,036 KB
testcase_34 AC 659 ms
129,164 KB
testcase_35 AC 656 ms
128,916 KB
testcase_36 AC 665 ms
128,888 KB
testcase_37 AC 658 ms
128,780 KB
testcase_38 AC 653 ms
129,168 KB
testcase_39 AC 646 ms
128,896 KB
testcase_40 AC 649 ms
128,936 KB
testcase_41 AC 655 ms
128,752 KB
testcase_42 AC 654 ms
129,056 KB
testcase_43 AC 75 ms
71,248 KB
testcase_44 AC 74 ms
71,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
D = []
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(N):
    D.append((A[i], B[i]))
D.sort()

ans = 10 ** 18
Bc = [0] * (N + 1)
ABc = [0] * (N + 1)
for i, t in enumerate(D):
    a, b = t
    Bc[i + 1] = Bc[i] + b
    ABc[i + 1] = ABc[i] + a * b
    
ans = 0
val = 10 ** 18
for i, t in enumerate(D):
    a, b = t
    s = -a * (Bc[N] - Bc[i + 1] * 2) + ABc[N] - ABc[i + 1] * 2
    if s < val:
        val = s
        ans = a

print(ans, val)
0