結果
| 問題 |
No.2548 Problem Selection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-25 13:05:50 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 382 bytes |
| コンパイル時間 | 97 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 21,824 KB |
| 最終ジャッジ日時 | 2024-09-26 10:21:55 |
| 合計ジャッジ時間 | 3,655 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 WA * 6 |
ソースコード
from itertools import pairwise
from collections import deque
N, 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 = 1 << 60
tmp = 0
for i in range(len(C)):
q.append(C[i])
tmp += C[i]
if len(q) == M - 1:
ans = min(ans, tmp)
tmp -= q.popleft()
print(ans)