結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-10-09 21:55:18
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 413 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 86,696 KB
実行使用メモリ 135,412 KB
最終ジャッジ日時 2023-09-27 16:42:59
合計ジャッジ時間 21,950 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,324 KB
testcase_01 AC 64 ms
71,084 KB
testcase_02 AC 66 ms
71,192 KB
testcase_03 AC 68 ms
70,924 KB
testcase_04 AC 67 ms
71,228 KB
testcase_05 AC 66 ms
71,148 KB
testcase_06 AC 66 ms
70,960 KB
testcase_07 AC 67 ms
71,232 KB
testcase_08 AC 67 ms
71,236 KB
testcase_09 AC 67 ms
71,348 KB
testcase_10 AC 65 ms
71,188 KB
testcase_11 AC 66 ms
71,316 KB
testcase_12 AC 66 ms
71,332 KB
testcase_13 AC 66 ms
70,916 KB
testcase_14 AC 67 ms
71,304 KB
testcase_15 AC 66 ms
70,956 KB
testcase_16 AC 64 ms
70,924 KB
testcase_17 AC 67 ms
71,140 KB
testcase_18 AC 387 ms
135,412 KB
testcase_19 AC 370 ms
130,656 KB
testcase_20 AC 214 ms
102,884 KB
testcase_21 AC 94 ms
78,256 KB
testcase_22 AC 232 ms
104,392 KB
testcase_23 AC 87 ms
76,524 KB
testcase_24 AC 286 ms
117,916 KB
testcase_25 AC 224 ms
103,696 KB
testcase_26 AC 124 ms
88,904 KB
testcase_27 AC 86 ms
76,528 KB
testcase_28 AC 405 ms
134,272 KB
testcase_29 AC 389 ms
133,956 KB
testcase_30 AC 391 ms
134,164 KB
testcase_31 AC 383 ms
134,036 KB
testcase_32 AC 389 ms
134,364 KB
testcase_33 AC 388 ms
134,480 KB
testcase_34 AC 394 ms
134,212 KB
testcase_35 AC 392 ms
134,336 KB
testcase_36 AC 413 ms
134,192 KB
testcase_37 AC 393 ms
134,336 KB
testcase_38 AC 397 ms
134,272 KB
testcase_39 AC 393 ms
134,236 KB
testcase_40 AC 386 ms
134,380 KB
testcase_41 AC 388 ms
134,264 KB
testcase_42 AC 386 ms
134,268 KB
testcase_43 AC 66 ms
71,300 KB
testcase_44 AC 67 ms
70,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys;input=sys.stdin.readline
N, = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
Z = sorted(list(zip(A,B)), key=lambda x:x[0])
C = [0]*(N+1)
D = [0]*(N+1)
E = [0]*(N+1)
F = [0]*(N+1)
for i in range(N):
    a, b = Z[i]
    C[i+1] += C[i] + b
    D[i+1] += D[i] - a*b
for i in range(N-1, -1, -1):
    a, b = Z[i]
    E[i] += E[i+1] + b
    F[i] += F[i+1] - a*b
m = 10**18
for i in range(N):
    a, b = Z[i]
    r = (-E[i+1]+C[i])*a +(-F[i+1]+D[i])
    if r < m:
        m = r
        mx = a
print(mx, m)

0