結果

問題 No.1251 絶対に間違ってはいけない最小化問題
コンテスト
ユーザー tanon710
提出日時 2020-10-15 22:56:17
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 495 ms / 2,000 ms
コード長 341 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 154 ms
コンパイル使用メモリ 85,492 KB
実行使用メモリ 140,956 KB
最終ジャッジ日時 2026-04-03 02:19:26
合計ジャッジ時間 18,781 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n=int(input())
ta=list(map(int,input().split()))
tb=list(map(int,input().split()))
ab=[[ta[i],tb[i]] for i in range(n)]
ab=sorted(ab,key=lambda x:x[0])
k=sum(tb)
persuit=(k+1)//2
acum=0
x=-1
for a,b in ab:
    if acum<=persuit<=acum+b:
        x=a
        break
    else:
        acum+=b
ans=0
for a,b in ab:
    ans+=abs(x-a)*b
print(x,ans)
0