結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー uni_pythonuni_python
提出日時 2020-10-09 22:30:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 799 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 112,972 KB
最終ジャッジ日時 2023-09-27 18:23:07
合計ジャッジ時間 27,030 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,312 KB
testcase_01 AC 73 ms
75,828 KB
testcase_02 AC 78 ms
75,792 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 AC 70 ms
75,428 KB
testcase_44 AC 127 ms
75,760 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()
    
    def calc(c):
        temp=0
        x=A[c]
        for i in range(N):
            temp+=B[i]*abs(x-A[i])
        return temp
        
    
    M=10**6+5
    left=0
    right=N-1
    
    for i in range(500):
        c1=(2*left+right)/3
        c2=(left+2*right)/3
        
        c1=int(c1)
        c2=int(c2)
        
        if calc(c1)<calc(c2):
            right=c2
        else:
            left=c1
            
    ll=calc(left)
    rr=calc(right)
    
    if ll<rr:
        print(A[left],ll)
    else:
        print(A[right],rr)

    
        
    


main()
0