結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー uni_pythonuni_python
提出日時 2020-10-09 22:09:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 875 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 109,880 KB
最終ジャッジ日時 2023-09-27 17:33:16
合計ジャッジ時間 44,082 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
74,976 KB
testcase_01 AC 79 ms
75,916 KB
testcase_02 AC 74 ms
76,128 KB
testcase_03 AC 71 ms
76,096 KB
testcase_04 AC 71 ms
75,936 KB
testcase_05 AC 70 ms
75,940 KB
testcase_06 AC 70 ms
75,988 KB
testcase_07 AC 72 ms
75,900 KB
testcase_08 AC 73 ms
76,096 KB
testcase_09 AC 73 ms
75,900 KB
testcase_10 AC 71 ms
76,028 KB
testcase_11 AC 70 ms
76,152 KB
testcase_12 AC 72 ms
75,992 KB
testcase_13 AC 73 ms
75,800 KB
testcase_14 AC 74 ms
75,988 KB
testcase_15 AC 75 ms
75,996 KB
testcase_16 AC 72 ms
76,152 KB
testcase_17 AC 72 ms
76,084 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 181 ms
76,876 KB
testcase_22 WA -
testcase_23 AC 150 ms
76,448 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 156 ms
76,440 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 71 ms
75,900 KB
testcase_44 AC 72 ms
75,904 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(x):
        temp=0
        for i in range(N):
            temp+=B[i]*abs(x-A[i])
        return temp
        
    
    M=10**6+5
    left=-M
    right=M
    
    for i in range(700):
        c1=(2*left+right)/3
        c2=(left+2*right)/3
        
        if calc(c1)<calc(c2):
            right=c2
        else:
            left=c1
            
            
    aaa=int((right+left)/2)
    
    ans=10**20
    ansx=0
    
    for i in range(100):
        ii=i-50
        x=aaa+0.5*ii
        temp=calc(x)
        if temp<ans:
            ans=temp
            ansx=x
            
    print(ansx,int(ans))
    
        
    


main()
0