結果
問題 | No.370 道路の掃除 |
ユーザー |
![]() |
提出日時 | 2016-05-13 23:40:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 248 bytes |
コンパイル時間 | 1,452 ms |
コンパイル使用メモリ | 160,208 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-14 16:47:36 |
合計ジャッジ時間 | 2,136 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n,m,a[1100]; int main(){ cin>>n>>m; for(int i=0;i<m;++i)cin>>a[i]; sort(a,a+m); int ans=1e9; for(int i=0;i+n-1<m;++i)ans=min(ans,min(abs(a[i]),abs(a[i+n-1]))+abs(a[i]-a[i+n-1])); cout<<ans<<endl; }