結果
| 問題 | No.2548 Problem Selection |
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2024-02-29 12:17:36 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 78 ms / 2,000 ms |
| コード長 | 380 bytes |
| 記録 | |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 85,008 KB |
| 実行使用メモリ | 99,428 KB |
| 最終ジャッジ日時 | 2026-04-15 21:40:51 |
| 合計ジャッジ時間 | 3,428 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
rlangevin