結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー taiga000629
提出日時 2020-10-09 23:24:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 353 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 81,844 KB
実行使用メモリ 135,096 KB
最終ジャッジ日時 2024-07-20 14:18:08
合計ジャッジ時間 15,757 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 WA * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=[0]*(3000000)
sumb=sum(b)
def f(x):
    global n
    res=0
    for i in range(n):
        res+=b[i]*abs(x-a[i])
    return res

for i in range(n):
    ans[a[i]]+=b[i]
a.sort()
num=0
for x in a:
    num+=ans[x]
    if num*2>=sumb:
        print(x,f(x))
        exit()

0