結果

問題 No.1251 絶対に間違ってはいけない最小化問題
ユーザー taiga000629
提出日時 2020-10-09 23:33:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 380 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 136,432 KB
最終ジャッジ日時 2024-07-20 14:24:47
合計ジャッジ時間 16,502 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=[0]*(3000000)
sumb=sum(b)
A=[a[i] for i in range(n)]
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