結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー H3PO4H3PO4
提出日時 2020-10-09 22:17:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 63,532 KB
最終ジャッジ日時 2023-09-27 17:53:13
合計ジャッジ時間 22,961 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
29,676 KB
testcase_01 AC 121 ms
29,672 KB
testcase_02 AC 121 ms
29,744 KB
testcase_03 AC 121 ms
29,748 KB
testcase_04 AC 120 ms
29,712 KB
testcase_05 AC 119 ms
29,704 KB
testcase_06 AC 120 ms
29,752 KB
testcase_07 AC 116 ms
29,708 KB
testcase_08 AC 118 ms
29,672 KB
testcase_09 AC 118 ms
29,720 KB
testcase_10 AC 119 ms
29,780 KB
testcase_11 AC 118 ms
29,728 KB
testcase_12 AC 121 ms
29,772 KB
testcase_13 AC 120 ms
29,676 KB
testcase_14 AC 119 ms
29,672 KB
testcase_15 AC 126 ms
29,700 KB
testcase_16 AC 118 ms
29,764 KB
testcase_17 AC 119 ms
29,708 KB
testcase_18 AC 316 ms
58,860 KB
testcase_19 AC 271 ms
61,256 KB
testcase_20 AC 200 ms
45,716 KB
testcase_21 AC 127 ms
31,948 KB
testcase_22 AC 205 ms
46,808 KB
testcase_23 AC 125 ms
31,876 KB
testcase_24 AC 238 ms
55,332 KB
testcase_25 AC 205 ms
46,540 KB
testcase_26 AC 145 ms
36,036 KB
testcase_27 AC 125 ms
31,296 KB
testcase_28 AC 281 ms
63,508 KB
testcase_29 AC 278 ms
63,312 KB
testcase_30 AC 283 ms
63,400 KB
testcase_31 AC 278 ms
63,512 KB
testcase_32 AC 281 ms
63,456 KB
testcase_33 AC 280 ms
63,528 KB
testcase_34 AC 281 ms
63,532 KB
testcase_35 AC 278 ms
63,460 KB
testcase_36 AC 279 ms
63,520 KB
testcase_37 AC 284 ms
63,508 KB
testcase_38 AC 281 ms
63,420 KB
testcase_39 AC 284 ms
63,504 KB
testcase_40 AC 281 ms
63,432 KB
testcase_41 AC 277 ms
63,512 KB
testcase_42 AC 275 ms
63,464 KB
testcase_43 AC 120 ms
29,768 KB
testcase_44 AC 119 ms
29,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import numpy as np

input = sys.stdin.readline

N = int(input())
AB = np.array([tuple(map(int, input().split())) for _ in range(2)])
AB = AB[:, AB[0].argsort()]

acc_ab_left = np.cumsum(AB[0] * AB[1])
acc_ab_right = np.cumsum((AB[0] * AB[1])[::-1])[::-1]
acc_b_left = np.cumsum(AB[1])
acc_b_right = np.cumsum(AB[1][::-1])[::-1]

y = np.zeros(N, dtype=int)
y[1:] += -acc_ab_left[:-1] + acc_b_left[:-1] * AB[0, 1:]
y[:-1] += acc_ab_right[1:] - acc_b_right[1:] * AB[0, :-1]
x = y.argmin()
print(AB[0, x], y[x])
0