結果
問題 |
No.2548 Problem Selection
|
ユーザー |
![]() |
提出日時 | 2024-11-12 22:37:33 |
言語 | Go (1.23.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 449 bytes |
コンパイル時間 | 12,892 ms |
コンパイル使用メモリ | 233,672 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-12 22:37:49 |
合計ジャッジ時間 | 14,555 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 |
other | AC * 3 WA * 22 |
ソースコード
package main import . "fmt" import . "os" import bf "bufio" import . "slices" func main() { rd:=bf.NewReader(Stdin) var n,m int Fscan(rd,&n,&m) a:=make([]int64,n) for i:=range a { Fscan(rd,&a[i]) } Sort(a) var x,y int var ans,s int64 for { if x-y < m { x++ if x>=n { break } s+=(a[x]-a[x-1])*(a[x]-a[x-1]) } else { if ans==0||s<ans { ans=s } y++ s-=(a[y]-a[y-1])*(a[y]-a[y-1]) } } Println(ans) }