結果
問題 | No.2438 Double Least Square |
ユーザー | kuroni |
提出日時 | 2023-08-18 22:40:11 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 368 bytes |
コンパイル時間 | 108 ms |
コンパイル使用メモリ | 10,496 KB |
実行使用メモリ | 92,608 KB |
最終ジャッジ日時 | 2023-08-18 22:40:38 |
合計ジャッジ時間 | 7,805 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | AC | 336 ms
56,868 KB |
testcase_02 | AC | 351 ms
56,808 KB |
testcase_03 | AC | 319 ms
56,708 KB |
testcase_04 | WA | - |
testcase_05 | AC | 352 ms
56,768 KB |
testcase_06 | AC | 335 ms
56,584 KB |
testcase_07 | AC | 322 ms
56,492 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 550 ms
56,688 KB |
testcase_21 | AC | 838 ms
56,808 KB |
testcase_22 | AC | 628 ms
57,064 KB |
testcase_23 | AC | 563 ms
56,660 KB |
testcase_24 | AC | 619 ms
56,924 KB |
testcase_25 | AC | 588 ms
57,072 KB |
testcase_26 | AC | 650 ms
56,756 KB |
testcase_27 | AC | 580 ms
56,720 KB |
testcase_28 | AC | 579 ms
56,828 KB |
testcase_29 | AC | 588 ms
56,824 KB |
testcase_30 | AC | 322 ms
56,600 KB |
testcase_31 | AC | 351 ms
56,828 KB |
testcase_32 | AC | 332 ms
92,608 KB |
ソースコード
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)