結果
| 問題 |
No.2548 Problem Selection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-18 21:00:10 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 843 bytes |
| コンパイル時間 | 3,435 ms |
| コンパイル使用メモリ | 233,040 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-18 21:00:16 |
| 合計ジャッジ時間 | 5,324 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 WA * 10 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:19: warning: 'mm' may be used uninitialized [-Wmaybe-uninitialized]
30 | for(int i=mm;i<mm+M-1;i++){
| ~^~~~~~~
main.cpp:25:15: note: 'mm' was declared here
25 | ll m=9e18,mm;
| ^~
ソースコード
#include<bits/stdc++.h>
#include <atcoder/all>
#ifdef LOCAL
#include <debug_print.hpp>
#define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (static_cast<void>(0))
#endif
using namespace atcoder;
using mint=modint998244353;
using namespace std;
using ll=long long;
using ul=unsigned long long;
int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1};
int dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
using Graph=vector<vector<int>>;
ll op(ll a,ll b){return a+b;}
ll e(){return 0;}
int main(){
int N,M;
cin>>N>>M;
vector<ll>A(N);
for(int i=0;i<N;i++)cin>>A[i];
sort(A.begin(),A.end());
ll m=9e18,mm;
for(int i=0;i<N-M+1;i++){
if(m>A[i+M-1]-A[i])m=A[i+M-1]-A[i],mm=i;
}
ll sum=0;
for(int i=mm;i<mm+M-1;i++){
sum+=(A[i+1]-A[i])*(A[i+1]-A[i]);
}
cout<<sum<<endl;
}