結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー uni_pythonuni_python
提出日時 2020-10-10 11:49:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 683 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 462 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 127,976 KB
最終ジャッジ日時 2023-09-27 21:21:47
合計ジャッジ時間 28,032 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,324 KB
testcase_01 AC 74 ms
71,260 KB
testcase_02 AC 73 ms
71,032 KB
testcase_03 AC 74 ms
71,548 KB
testcase_04 AC 73 ms
71,064 KB
testcase_05 AC 76 ms
71,284 KB
testcase_06 AC 75 ms
71,404 KB
testcase_07 AC 75 ms
71,256 KB
testcase_08 AC 74 ms
71,432 KB
testcase_09 AC 76 ms
71,212 KB
testcase_10 AC 76 ms
71,032 KB
testcase_11 AC 76 ms
71,260 KB
testcase_12 AC 73 ms
71,344 KB
testcase_13 AC 75 ms
71,260 KB
testcase_14 AC 75 ms
71,408 KB
testcase_15 AC 77 ms
71,368 KB
testcase_16 AC 76 ms
71,192 KB
testcase_17 AC 75 ms
71,316 KB
testcase_18 AC 648 ms
127,344 KB
testcase_19 AC 617 ms
121,532 KB
testcase_20 AC 364 ms
102,188 KB
testcase_21 AC 115 ms
78,528 KB
testcase_22 AC 394 ms
104,212 KB
testcase_23 AC 104 ms
77,464 KB
testcase_24 AC 512 ms
115,404 KB
testcase_25 AC 395 ms
105,560 KB
testcase_26 AC 181 ms
87,740 KB
testcase_27 AC 106 ms
77,388 KB
testcase_28 AC 677 ms
127,812 KB
testcase_29 AC 670 ms
127,352 KB
testcase_30 AC 671 ms
127,636 KB
testcase_31 AC 680 ms
127,680 KB
testcase_32 AC 676 ms
127,592 KB
testcase_33 AC 666 ms
127,668 KB
testcase_34 AC 675 ms
127,604 KB
testcase_35 AC 679 ms
127,964 KB
testcase_36 AC 673 ms
127,332 KB
testcase_37 AC 682 ms
127,976 KB
testcase_38 AC 677 ms
127,604 KB
testcase_39 AC 673 ms
127,416 KB
testcase_40 AC 683 ms
127,856 KB
testcase_41 AC 676 ms
127,304 KB
testcase_42 AC 678 ms
127,860 KB
testcase_43 AC 74 ms
71,352 KB
testcase_44 AC 75 ms
71,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    import bisect
    
    N=I()
    A=LI()
    B=LI()
    A,B = zip(*sorted(zip(A, B)))
    
    def calc(x):
        temp=0
        for i in range(N):
            temp+=B[i]*abs(x-A[i])
        return temp
    
    SB=sum(B)
    num=(SB+1)//2

    cnt=0
    i=-1
    while cnt<num:
        # print(i,cnt,num)
        i+=1
        cnt+=B[i]
    print(A[i],calc(A[i]))

main()
0