結果
| 問題 | No.1251 絶対に間違ってはいけない最小化問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-21 11:02:20 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 284 ms / 2,000 ms |
| コード長 | 476 bytes |
| 記録 | |
| コンパイル時間 | 274 ms |
| コンパイル使用メモリ | 85,176 KB |
| 実行使用メモリ | 122,112 KB |
| 最終ジャッジ日時 | 2026-03-21 11:02:34 |
| 合計ジャッジ時間 | 12,361 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
def f(x):
tot = 0
for i in range(N):
tot += B[i]*abs(x-A[i])
return tot
low = -10**6-10
high = 10**6+10
while high-low>2:
left = (2*low+high)//3
right = (low+2*high)//3
if f(right)>f(left):
high = right
else:
low = left
r = f((low+2*high)//3)
l = f((2*low+high)//3)
if r>l:
print((2*low+high)//3,l)
else:
print((low+2*high)//3,r)