結果

問題 No.2548 Problem Selection
ユーザー cologne
提出日時 2025-06-12 16:33:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 101,632 KB
最終ジャッジ日時 2025-06-12 16:34:15
合計ジャッジ時間 3,098 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #


from itertools import accumulate


def main():
    n, m = map(int, input().split())
    *a, = map(int, input().split())
    a.sort()
    a = [0] + [(a[i] - a[i-1])**2 for i in range(1, n)]
    a = list(accumulate(a))
    print(min(a[i+m-1] - a[i] for i in range(n-m+1)))


if __name__ == '__main__':
    main()
0