結果
| 問題 | No.1251 絶対に間違ってはいけない最小化問題 |
| コンテスト | |
| ユーザー |
uni_python
|
| 提出日時 | 2020-10-10 11:49:06 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 703 ms / 2,000 ms |
| コード長 | 546 bytes |
| コンパイル時間 | 177 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 126,844 KB |
| 最終ジャッジ日時 | 2024-07-20 15:53:30 |
| 合計ジャッジ時間 | 26,793 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
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
SB=sum(B)
num=(SB+1)//2
cnt=0
i=-1
while cnt<num:
# print(i,cnt,num)
i+=1
cnt+=B[i]
print(A[i],calc(A[i]))
main()
uni_python