結果
| 問題 | No.2438 Double Least Square |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-18 22:40:11 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 368 bytes |
| 記録 | |
| コンパイル時間 | 724 ms |
| コンパイル使用メモリ | 20,568 KB |
| 実行使用メモリ | 86,552 KB |
| 最終ジャッジ日時 | 2026-05-22 10:38:33 |
| 合計ジャッジ時間 | 9,342 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 1 TLE * 3 -- * 26 |
ソースコード
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)