結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー momoyuumomoyuu
提出日時 2022-08-03 03:15:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 655 ms / 2,000 ms
コード長 374 bytes
コンパイル時間 1,378 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 128,952 KB
最終ジャッジ日時 2023-10-01 03:56:37
合計ジャッジ時間 27,495 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,092 KB
testcase_01 AC 71 ms
71,244 KB
testcase_02 AC 70 ms
71,324 KB
testcase_03 AC 69 ms
71,248 KB
testcase_04 AC 72 ms
71,484 KB
testcase_05 AC 71 ms
71,252 KB
testcase_06 AC 73 ms
71,232 KB
testcase_07 AC 72 ms
71,376 KB
testcase_08 AC 73 ms
71,360 KB
testcase_09 AC 75 ms
71,392 KB
testcase_10 AC 74 ms
71,252 KB
testcase_11 AC 72 ms
71,244 KB
testcase_12 AC 73 ms
71,324 KB
testcase_13 AC 71 ms
71,484 KB
testcase_14 AC 73 ms
71,072 KB
testcase_15 AC 72 ms
71,408 KB
testcase_16 AC 72 ms
71,248 KB
testcase_17 AC 73 ms
71,236 KB
testcase_18 AC 608 ms
126,812 KB
testcase_19 AC 596 ms
122,656 KB
testcase_20 AC 354 ms
101,736 KB
testcase_21 AC 113 ms
77,964 KB
testcase_22 AC 388 ms
103,444 KB
testcase_23 AC 103 ms
77,760 KB
testcase_24 AC 489 ms
119,060 KB
testcase_25 AC 371 ms
101,844 KB
testcase_26 AC 170 ms
87,996 KB
testcase_27 AC 106 ms
77,568 KB
testcase_28 AC 641 ms
128,884 KB
testcase_29 AC 632 ms
128,784 KB
testcase_30 AC 654 ms
128,664 KB
testcase_31 AC 652 ms
128,800 KB
testcase_32 AC 636 ms
128,892 KB
testcase_33 AC 632 ms
128,728 KB
testcase_34 AC 631 ms
128,872 KB
testcase_35 AC 627 ms
128,736 KB
testcase_36 AC 633 ms
128,776 KB
testcase_37 AC 642 ms
128,952 KB
testcase_38 AC 629 ms
128,872 KB
testcase_39 AC 628 ms
128,788 KB
testcase_40 AC 627 ms
128,892 KB
testcase_41 AC 630 ms
128,780 KB
testcase_42 AC 655 ms
128,732 KB
testcase_43 AC 74 ms
71,224 KB
testcase_44 AC 73 ms
71,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
l = []
for i in range(N):
    l.append((A[i],B[i]))
l.sort()
a = 0
for i in range(N):
    a += B[i]
a //= 2

now = 0
o = 0
for i in range(N):
    p,q = l[i]
    now += q
    if now >= a:
        o = p
        break

sum = 0
for i in range(N):
    sum += B[i] * abs(o-A[i])

print(o,sum)
0