結果
| 問題 |
No.370 道路の掃除
|
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2016-05-13 23:45:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 413 bytes |
| コンパイル時間 | 1,686 ms |
| コンパイル使用メモリ | 172,272 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-14 16:48:13 |
| 合計ジャッジ時間 | 2,607 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init;
int main() {
int n,m;
cin >> n >> m;
vector<int> d(m);
for(auto& it : d)cin >> it;
sort(d.begin(),d.end());
int res=114514;
for(int i = 0,j= n - 1; j < m; i++,j++){
res=min(res,min(abs(d[i]),abs(d[j]))+abs(d[i]-d[j]));
}
cout<< res << endl;
return 0;
}
btk