結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー uni_pythonuni_python
提出日時 2020-10-10 11:17:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 846 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 86,960 KB
実行使用メモリ 128,196 KB
最終ジャッジ日時 2023-09-27 21:13:38
合計ジャッジ時間 29,890 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,436 KB
testcase_01 AC 78 ms
71,204 KB
testcase_02 AC 74 ms
71,212 KB
testcase_03 AC 75 ms
71,244 KB
testcase_04 AC 77 ms
71,384 KB
testcase_05 AC 75 ms
71,264 KB
testcase_06 AC 75 ms
71,284 KB
testcase_07 AC 75 ms
71,240 KB
testcase_08 AC 76 ms
71,240 KB
testcase_09 AC 75 ms
71,376 KB
testcase_10 AC 76 ms
71,180 KB
testcase_11 AC 76 ms
71,176 KB
testcase_12 AC 77 ms
71,040 KB
testcase_13 AC 74 ms
71,316 KB
testcase_14 AC 75 ms
71,200 KB
testcase_15 AC 75 ms
71,328 KB
testcase_16 AC 75 ms
71,376 KB
testcase_17 AC 76 ms
71,148 KB
testcase_18 WA -
testcase_19 AC 626 ms
121,520 KB
testcase_20 AC 368 ms
101,920 KB
testcase_21 AC 111 ms
77,584 KB
testcase_22 AC 400 ms
104,424 KB
testcase_23 AC 104 ms
77,460 KB
testcase_24 AC 526 ms
115,196 KB
testcase_25 AC 402 ms
105,768 KB
testcase_26 AC 183 ms
87,704 KB
testcase_27 AC 108 ms
77,476 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 682 ms
127,552 KB
testcase_31 WA -
testcase_32 AC 690 ms
127,608 KB
testcase_33 AC 691 ms
127,780 KB
testcase_34 AC 692 ms
127,888 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 691 ms
127,956 KB
testcase_39 AC 694 ms
127,648 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 76 ms
71,260 KB
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

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()
    A,B = zip(*sorted(zip(A, B)))
    
    def calc(x):
        temp=0
        for i in range(N):
            temp+=B[i]*abs(x-A[i])
        return temp
    
    N2=sum(B)
    num=(N2-1)//2
    if N2%2:
        cnt=0
        i=-1
        while cnt<num:
            # print(i,cnt,num)
            i+=1
            cnt+=B[i]
        print(A[i],calc(A[i]))
    else:
        cnt=0
        i=-1
        num2=num+1
        while cnt<num:
            i+=1
            cnt+=B[i]
        i2=i
        if cnt<num2:
            i2+=1
            
        x=(A[i]+A[i2])/2
        print(x,int(calc(x)))
        
            

main()
0