結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー anagohirameanagohirame
提出日時 2020-10-09 22:25:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 689 ms / 2,000 ms
コード長 423 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 129,200 KB
最終ジャッジ日時 2023-09-27 18:10:12
合計ジャッジ時間 28,690 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,392 KB
testcase_01 AC 71 ms
71,188 KB
testcase_02 AC 72 ms
71,228 KB
testcase_03 AC 74 ms
71,012 KB
testcase_04 AC 70 ms
71,324 KB
testcase_05 AC 70 ms
71,332 KB
testcase_06 AC 70 ms
71,360 KB
testcase_07 AC 70 ms
71,008 KB
testcase_08 AC 73 ms
71,200 KB
testcase_09 AC 72 ms
71,136 KB
testcase_10 AC 70 ms
71,408 KB
testcase_11 AC 70 ms
71,308 KB
testcase_12 AC 72 ms
71,448 KB
testcase_13 AC 73 ms
71,156 KB
testcase_14 AC 71 ms
71,236 KB
testcase_15 AC 74 ms
71,368 KB
testcase_16 AC 70 ms
71,020 KB
testcase_17 AC 73 ms
71,324 KB
testcase_18 AC 689 ms
128,668 KB
testcase_19 AC 600 ms
122,612 KB
testcase_20 AC 360 ms
101,960 KB
testcase_21 AC 111 ms
77,876 KB
testcase_22 AC 388 ms
103,552 KB
testcase_23 AC 105 ms
77,776 KB
testcase_24 AC 504 ms
118,988 KB
testcase_25 AC 376 ms
102,748 KB
testcase_26 AC 175 ms
88,132 KB
testcase_27 AC 105 ms
77,816 KB
testcase_28 AC 647 ms
128,820 KB
testcase_29 AC 647 ms
129,048 KB
testcase_30 AC 652 ms
128,920 KB
testcase_31 AC 646 ms
128,872 KB
testcase_32 AC 649 ms
128,912 KB
testcase_33 AC 647 ms
128,872 KB
testcase_34 AC 649 ms
128,908 KB
testcase_35 AC 654 ms
128,904 KB
testcase_36 AC 655 ms
128,604 KB
testcase_37 AC 648 ms
129,080 KB
testcase_38 AC 647 ms
129,200 KB
testcase_39 AC 656 ms
128,816 KB
testcase_40 AC 645 ms
128,908 KB
testcase_41 AC 654 ms
128,924 KB
testcase_42 AC 651 ms
129,012 KB
testcase_43 AC 71 ms
71,408 KB
testcase_44 AC 72 ms
71,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for x, y in zip(a, b):
	c.append((x, y))
c.sort()
v = 0
for x, y in c:
	v += y * abs(c[0][0] - x)

ans1, ans2 = c[0][0], v
l, r = c[0][1], sum(b) - c[0][1]
for i in range(1, n):
	v += l * (c[i][0] - c[i-1][0])
	v -= r * (c[i][0] - c[i-1][0])
	l += c[i][1]
	r -= c[i][1]
	if v < ans2:
		ans1, ans2 = c[i][0], v
print(ans1, ans2)
0