結果
問題 | No.2548 Problem Selection |
ユーザー |
|
提出日時 | 2023-11-25 13:37:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 199 ms / 2,000 ms |
コード長 | 410 bytes |
コンパイル時間 | 410 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 21,388 KB |
最終ジャッジ日時 | 2024-09-26 10:29:36 |
合計ジャッジ時間 | 3,724 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
from itertools import pairwisefrom collections import dequeN, M = map(int, input().split())A = list(map(int, input().split()))A.sort()C = []for x, y in pairwise(A):C.append((y - x) ** 2)q = deque()ans = float("inf")tmp = 0for i in range(len(C)):q.append(C[i])tmp += C[i]if len(q) == M - 1:ans = min(ans, tmp)tmp -= q.popleft()if M == 1:ans = 0print(ans)