結果
| 問題 |
No.2438 Double Least Square
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-18 23:02:02 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 349 bytes |
| コンパイル時間 | 100 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 122,736 KB |
| 最終ジャッジ日時 | 2024-11-28 09:38:13 |
| 合計ジャッジ時間 | 59,321 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 13 WA * 15 TLE * 2 |
ソースコード
from scipy.optimize import minimize
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='BFGS', tol=1e-9).fun)