結果

問題 No.2548 Problem Selection
ユーザー 👑 KA37RIKA37RI
提出日時 2023-11-25 16:10:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 255 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 21,188 KB
最終ジャッジ日時 2023-11-25 16:10:57
合計ジャッジ時間 3,075 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
18,064 KB
testcase_01 AC 55 ms
12,832 KB
testcase_02 AC 155 ms
20,592 KB
testcase_03 AC 38 ms
11,264 KB
testcase_04 AC 114 ms
16,476 KB
testcase_05 AC 130 ms
20,628 KB
testcase_06 AC 45 ms
11,392 KB
testcase_07 AC 133 ms
17,824 KB
testcase_08 AC 142 ms
18,932 KB
testcase_09 AC 149 ms
19,236 KB
testcase_10 AC 176 ms
21,188 KB
testcase_11 AC 138 ms
21,188 KB
testcase_12 AC 118 ms
21,188 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 28 ms
9,984 KB
testcase_16 AC 28 ms
9,984 KB
testcase_17 WA -
testcase_18 AC 27 ms
9,984 KB
testcase_19 AC 28 ms
9,984 KB
testcase_20 WA -
testcase_21 AC 27 ms
9,984 KB
testcase_22 AC 27 ms
9,984 KB
testcase_23 AC 27 ms
9,984 KB
testcase_24 AC 27 ms
9,984 KB
testcase_25 AC 27 ms
9,984 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort()
d = []
for i in range(1, n):
	d.append((a[i] - a[i-1]) ** 2)
ans = 10 ** 18
s = sum(d[:m-1])
for i in range(n - m):
	s += d[i+m-1] - d[i]
	ans = min(s, ans)
print(ans)
0