結果

問題 No.2548 Problem Selection
ユーザー titiatitia
提出日時 2023-11-28 07:48:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 203 ms / 2,000 ms
コード長 262 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 21,048 KB
最終ジャッジ日時 2023-11-28 07:48:14
合計ジャッジ時間 4,030 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
17,924 KB
testcase_01 AC 60 ms
12,564 KB
testcase_02 AC 181 ms
20,452 KB
testcase_03 AC 39 ms
11,136 KB
testcase_04 AC 117 ms
16,332 KB
testcase_05 AC 136 ms
20,488 KB
testcase_06 AC 47 ms
11,392 KB
testcase_07 AC 141 ms
17,684 KB
testcase_08 AC 137 ms
18,788 KB
testcase_09 AC 193 ms
19,100 KB
testcase_10 AC 203 ms
21,048 KB
testcase_11 AC 148 ms
21,048 KB
testcase_12 AC 122 ms
21,048 KB
testcase_13 AC 28 ms
9,984 KB
testcase_14 AC 28 ms
9,984 KB
testcase_15 AC 28 ms
9,984 KB
testcase_16 AC 28 ms
9,984 KB
testcase_17 AC 28 ms
9,984 KB
testcase_18 AC 28 ms
9,984 KB
testcase_19 AC 29 ms
9,984 KB
testcase_20 AC 28 ms
9,984 KB
testcase_21 AC 28 ms
9,984 KB
testcase_22 AC 28 ms
9,984 KB
testcase_23 AC 28 ms
9,984 KB
testcase_24 AC 28 ms
9,984 KB
testcase_25 AC 28 ms
9,984 KB
testcase_26 AC 28 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M=map(int,input().split())
A=list(map(int,input().split()))

A.sort()

score=0
for i in range(1,M):
    score+=(A[i]-A[i-1])**2

LANS=score

for i in range(M,N):
    score+=(A[i]-A[i-1])**2
    score-=(A[i-M+1]-A[i-M])**2
    LANS=min(LANS,score)

print(LANS)
0