結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー uni_pythonuni_python
提出日時 2020-10-09 22:07:08
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 109,672 KB
最終ジャッジ日時 2023-09-27 17:20:01
合計ジャッジ時間 22,833 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,152 KB
testcase_01 AC 68 ms
75,636 KB
testcase_02 AC 66 ms
76,132 KB
testcase_03 AC 66 ms
75,800 KB
testcase_04 AC 66 ms
75,932 KB
testcase_05 AC 67 ms
75,888 KB
testcase_06 AC 67 ms
75,988 KB
testcase_07 AC 68 ms
75,888 KB
testcase_08 AC 67 ms
76,020 KB
testcase_09 AC 66 ms
75,836 KB
testcase_10 AC 66 ms
75,836 KB
testcase_11 AC 67 ms
75,796 KB
testcase_12 AC 68 ms
75,932 KB
testcase_13 AC 67 ms
75,784 KB
testcase_14 AC 65 ms
75,924 KB
testcase_15 AC 68 ms
75,876 KB
testcase_16 AC 68 ms
75,844 KB
testcase_17 AC 66 ms
75,920 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 98 ms
76,596 KB
testcase_22 WA -
testcase_23 AC 91 ms
76,452 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 90 ms
76,444 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 65 ms
71,036 KB
testcase_44 AC 67 ms
75,788 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(200):
        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(10):
        ii=i-5
        x=aaa+0.5*ii
        temp=calc(x)
        if temp<ans:
            ans=temp
            ansx=x
            
    print(ansx,int(ans))
    
        
    


main()
0