結果

問題 No.2548 Problem Selection
ユーザー hato336hato336
提出日時 2023-11-25 13:04:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 567 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 109,880 KB
最終ジャッジ日時 2023-11-25 13:05:05
合計ジャッジ時間 5,672 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
99,896 KB
testcase_01 AC 157 ms
90,552 KB
testcase_02 AC 187 ms
108,472 KB
testcase_03 AC 153 ms
89,400 KB
testcase_04 AC 188 ms
99,768 KB
testcase_05 AC 185 ms
105,272 KB
testcase_06 AC 148 ms
89,400 KB
testcase_07 AC 176 ms
103,224 KB
testcase_08 AC 177 ms
103,096 KB
testcase_09 AC 181 ms
106,808 KB
testcase_10 AC 194 ms
109,880 KB
testcase_11 AC 185 ms
106,168 KB
testcase_12 AC 188 ms
104,376 KB
testcase_13 AC 134 ms
85,176 KB
testcase_14 AC 132 ms
85,176 KB
testcase_15 AC 133 ms
85,176 KB
testcase_16 AC 132 ms
85,176 KB
testcase_17 AC 133 ms
85,176 KB
testcase_18 AC 134 ms
85,176 KB
testcase_19 AC 134 ms
85,176 KB
testcase_20 AC 135 ms
85,176 KB
testcase_21 AC 132 ms
85,176 KB
testcase_22 AC 133 ms
85,176 KB
testcase_23 AC 132 ms
85,176 KB
testcase_24 AC 133 ms
85,176 KB
testcase_25 AC 132 ms
85,176 KB
testcase_26 AC 135 ms
85,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#n = int(input())
#
#alist = []
#s = input()
n,m = map(int,input().split())
#for i in range(n):
#    alist.append(list(map(int,input().split())))
alist = list(map(int,input().split()))
alist.sort()
ans = 0
for i in range(m-1):
    ans += (alist[i+1]-alist[i])**2
a = [ans]
for i in range(m-1,n-1):
    ans -= (alist[i-m+1] - alist[i-m+2])**2
    ans += (alist[i]-alist[i+1])**2
    a.append(ans)
print(min(a))
0