結果
問題 | No.370 道路の掃除 |
ユーザー |
|
提出日時 | 2024-09-21 19:34:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 430 bytes |
コンパイル時間 | 2,204 ms |
コンパイル使用メモリ | 198,732 KB |
最終ジャッジ日時 | 2025-02-24 11:24:31 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 RE * 8 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;int main(){cin.tie(nullptr);ios::sync_with_stdio(false);ll N,M;cin>>N>>M;vector<ll> A(N);for(int i=0;i<M;i++)cin>>A[i];sort(A.begin(),A.end());ll an=1e18;for(int i=0;i<M-N+1;i++){ll L=A[i];ll R=A[i+N-1];an=min(an,abs(L)+R-L);an=min(an,abs(R)+R-L);}cout<<an<<endl;}