結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー shotoyooshotoyoo
提出日時 2020-10-09 22:57:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 564 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 129,020 KB
最終ジャッジ日時 2023-09-27 19:09:48
合計ジャッジ時間 23,692 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
71,412 KB
testcase_01 AC 62 ms
71,412 KB
testcase_02 AC 61 ms
71,188 KB
testcase_03 AC 61 ms
71,228 KB
testcase_04 AC 62 ms
71,140 KB
testcase_05 AC 63 ms
71,184 KB
testcase_06 AC 65 ms
71,296 KB
testcase_07 AC 61 ms
71,296 KB
testcase_08 AC 61 ms
71,248 KB
testcase_09 AC 62 ms
71,252 KB
testcase_10 AC 61 ms
71,244 KB
testcase_11 AC 63 ms
71,012 KB
testcase_12 AC 64 ms
71,292 KB
testcase_13 AC 62 ms
71,416 KB
testcase_14 AC 62 ms
71,436 KB
testcase_15 AC 62 ms
71,252 KB
testcase_16 AC 62 ms
71,144 KB
testcase_17 AC 62 ms
71,248 KB
testcase_18 AC 537 ms
128,532 KB
testcase_19 AC 503 ms
122,572 KB
testcase_20 AC 313 ms
102,812 KB
testcase_21 AC 95 ms
77,628 KB
testcase_22 AC 324 ms
103,264 KB
testcase_23 AC 87 ms
77,404 KB
testcase_24 AC 421 ms
119,316 KB
testcase_25 AC 321 ms
102,752 KB
testcase_26 AC 149 ms
87,660 KB
testcase_27 AC 88 ms
77,448 KB
testcase_28 AC 544 ms
128,748 KB
testcase_29 AC 555 ms
128,796 KB
testcase_30 AC 549 ms
129,020 KB
testcase_31 AC 545 ms
128,772 KB
testcase_32 AC 555 ms
128,780 KB
testcase_33 AC 544 ms
128,888 KB
testcase_34 AC 564 ms
128,640 KB
testcase_35 AC 554 ms
128,904 KB
testcase_36 AC 551 ms
128,768 KB
testcase_37 AC 549 ms
128,940 KB
testcase_38 AC 549 ms
128,708 KB
testcase_39 AC 553 ms
129,000 KB
testcase_40 AC 558 ms
128,912 KB
testcase_41 AC 547 ms
128,956 KB
testcase_42 AC 555 ms
128,784 KB
testcase_43 AC 64 ms
71,428 KB
testcase_44 AC 60 ms
71,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ab = list(zip(a,b))
ab.sort()
v0 = ab[0][1]
v1 = sum(b) - v0
i = 0
while v0<v1:
    i += 1
    v0 += ab[i][1]
    v1 -= ab[i][1]
if v0==v1:
    aa,val = ab[i][0], sum(bb*abs(aa-ab[i][0]) for aa,bb in ab)
else:
    aa = ab[i][0]
    val = sum(bb*abs(aa-ab[i][0]) for aa,bb in ab)
print(aa,val)
0