結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー uni_pythonuni_python
提出日時 2020-10-10 11:30:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 867 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 109,764 KB
最終ジャッジ日時 2023-09-27 21:17:39
合計ジャッジ時間 48,031 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,232 KB
testcase_01 AC 73 ms
75,492 KB
testcase_02 AC 76 ms
75,820 KB
testcase_03 AC 75 ms
76,000 KB
testcase_04 AC 76 ms
75,756 KB
testcase_05 AC 74 ms
75,836 KB
testcase_06 AC 73 ms
75,772 KB
testcase_07 AC 75 ms
75,540 KB
testcase_08 AC 74 ms
76,072 KB
testcase_09 AC 75 ms
76,084 KB
testcase_10 AC 75 ms
76,056 KB
testcase_11 AC 74 ms
76,100 KB
testcase_12 AC 76 ms
76,052 KB
testcase_13 AC 75 ms
75,984 KB
testcase_14 AC 73 ms
76,184 KB
testcase_15 AC 77 ms
76,248 KB
testcase_16 AC 75 ms
76,156 KB
testcase_17 AC 75 ms
76,100 KB
testcase_18 AC 1,565 ms
109,280 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 189 ms
77,360 KB
testcase_22 WA -
testcase_23 AC 156 ms
77,176 KB
testcase_24 AC 1,291 ms
100,964 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 166 ms
77,308 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1,646 ms
109,336 KB
testcase_32 AC 1,805 ms
109,360 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 1,806 ms
109,324 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 1,657 ms
109,220 KB
testcase_41 AC 1,666 ms
109,424 KB
testcase_42 AC 1,639 ms
109,296 KB
testcase_43 AC 69 ms
74,976 KB
testcase_44 AC 74 ms
75,884 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(300):
        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(20):
        ii=i-10
        x=ansx+0.5*ii
        temp=calc(x)
        if temp<ans:
            ans=temp
            ansx=x
            
    print(ansx,int(ans))
    
        
    


main()
0