結果
問題 |
No.2548 Problem Selection
|
ユーザー |
![]() |
提出日時 | 2024-02-29 12:17:36 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 100 ms / 2,000 ms |
コード長 | 380 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 82,136 KB |
実行使用メモリ | 93,604 KB |
最終ジャッジ日時 | 2024-09-29 12:40:34 |
合計ジャッジ時間 | 3,436 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
from collections import * N, M = map(int, input().split()) A = sorted(list(map(int, input().split()))) Q = deque() now = 0 for i in range(M): Q.append(A[i]) if len(Q) >= 2: now += (Q[-1] - Q[-2])**2 ans = now for i in range(M, N): Q.append(A[i]) now += (Q[-1] - Q[-2]) ** 2 now -= (Q[0] - Q[1]) ** 2 Q.popleft() ans = min(ans, now) print(ans)