結果

問題 No.2548 Problem Selection
ユーザー lloyzlloyz
提出日時 2023-11-27 00:16:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 299 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 85,028 KB
最終ジャッジ日時 2023-11-27 00:16:14
合計ジャッジ時間 2,955 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
79,008 KB
testcase_01 AC 47 ms
67,872 KB
testcase_02 AC 80 ms
85,028 KB
testcase_03 AC 50 ms
64,264 KB
testcase_04 AC 61 ms
76,252 KB
testcase_05 AC 76 ms
85,000 KB
testcase_06 AC 41 ms
62,064 KB
testcase_07 AC 67 ms
77,972 KB
testcase_08 AC 71 ms
81,416 KB
testcase_09 AC 73 ms
82,916 KB
testcase_10 AC 79 ms
84,956 KB
testcase_11 AC 77 ms
84,956 KB
testcase_12 AC 78 ms
84,956 KB
testcase_13 AC 34 ms
53,460 KB
testcase_14 WA -
testcase_15 AC 33 ms
53,460 KB
testcase_16 AC 32 ms
53,460 KB
testcase_17 AC 33 ms
53,460 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 WA -
testcase_21 AC 35 ms
53,460 KB
testcase_22 RE -
testcase_23 AC 33 ms
53,460 KB
testcase_24 AC 33 ms
53,460 KB
testcase_25 RE -
testcase_26 AC 33 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

n, m = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
ans = 10**18
res = 0
for i in range(1, n):
    res += (A[i] - A[i - 1])**2
    if i >= m - 1:
        ans = min(ans, res)
        res -= (A[i - m + 2] - A[i - m + 1])**2
print(ans)
0