結果
| 問題 |
No.2438 Double Least Square
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-18 23:44:44 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 363 bytes |
| コンパイル時間 | 349 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 142,160 KB |
| 最終ジャッジ日時 | 2024-11-28 11:22:04 |
| 合計ジャッジ時間 | 86,847 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 9 TLE * 21 |
ソースコード
import scipy.optimize as opt
(N,),(H,),*xy=[list(map(int,s.split())) for s in open(0)]
def f(a):
a1,a2=a
ret=0
for x,y in xy:
ret+=min((y-a1*x)**2,(y-a2*x-H)**2)
return ret
#print(opt.dual_annealing(f,[(0,500),(-500,500)],maxiter=500).fun)
print(opt.basinhopping(f,(0,0)).fun)
#print(opt.differential_evolution(f,[(0,500),(-500,500)]))