結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー uni_pythonuni_python
提出日時 2020-10-10 11:27:48
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 866 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 112,964 KB
最終ジャッジ日時 2023-09-27 21:14:51
合計ジャッジ時間 28,788 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,028 KB
testcase_01 AC 80 ms
75,848 KB
testcase_02 AC 80 ms
75,756 KB
testcase_03 AC 79 ms
75,852 KB
testcase_04 AC 83 ms
75,732 KB
testcase_05 AC 81 ms
75,760 KB
testcase_06 AC 81 ms
75,728 KB
testcase_07 AC 83 ms
75,716 KB
testcase_08 AC 82 ms
76,244 KB
testcase_09 AC 82 ms
76,240 KB
testcase_10 AC 84 ms
75,752 KB
testcase_11 AC 80 ms
75,748 KB
testcase_12 AC 82 ms
76,080 KB
testcase_13 AC 83 ms
76,276 KB
testcase_14 AC 83 ms
76,008 KB
testcase_15 AC 81 ms
76,240 KB
testcase_16 AC 82 ms
76,112 KB
testcase_17 AC 83 ms
76,128 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 WA -
testcase_21 AC 283 ms
77,228 KB
testcase_22 WA -
testcase_23 AC 223 ms
76,640 KB
testcase_24 TLE -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 232 ms
76,800 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

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(500):
        c1=(2*left+right)//3
        c2=(left+2*right)//3
        
        if calc(c1)<calc(c2):
            right=c2
        else:
            left=c1
            
            
    ansx=int((right+left)//2)
    ans=calc(ansx)
    
    for i in range(10):
        ii=i-5
        x=ansx+0.5*ii
        temp=calc(x)
        if temp<ans:
            ans=temp
            ansx=x
            
    print(ansx,int(ans))
    
        
    


main()
0