結果
| 問題 |
No.370 道路の掃除
|
| コンテスト | |
| ユーザー |
tonegawa
|
| 提出日時 | 2020-08-16 19:25:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 432 bytes |
| コンパイル時間 | 1,076 ms |
| コンパイル使用メモリ | 95,980 KB |
| 最終ジャッジ日時 | 2025-01-13 02:03:25 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <iostream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;
ll n, m, d[1010];
int main()
{
cin >> n >> m;
for (int i = 0; i < m; ++i)
cin >> d[i];
sort(d, d + m);
ll ans = 1 << 30;
for (int i = 0; i < m - n + 1; ++i)
{
ans = min(ans, min(abs(d[i + n - 1]), abs(d[i])) + d[i + n - 1] - d[i]);
}
cout << ans << endl;
return 0;
}
tonegawa