結果
| 問題 |
No.2438 Double Least Square
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-18 22:40:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 368 bytes |
| コンパイル時間 | 285 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 65,024 KB |
| 最終ジャッジ日時 | 2024-11-28 08:46:49 |
| 合計ジャッジ時間 | 3,538 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 30 |
ソースコード
from scipy.optimize import minimize
from math import sqrt
n = int(input())
h = int(input())
points = [tuple(map(int, input().split())) for i in range(n)]
def f(params):
a1, a2 = params
ret = 0
for x, y in points:
ret += min((y - (a1 * x + h)) ** 2, (y - a2 * x) ** 2)
return ret
print(minimize(f, (0, 0), args=(), method='Nelder-Mead').fun)