結果

問題 No.2548 Problem Selection
ユーザー 👑 KA37RIKA37RI
提出日時 2023-11-25 16:08:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 255 bytes
コンパイル時間 397 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,388 KB
最終ジャッジ日時 2024-09-26 10:54:38
合計ジャッジ時間 3,140 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20 WA * 5
権限があれば一括ダウンロードができます

ソースコード

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