結果
問題 |
No.370 道路の掃除
|
ユーザー |
|
提出日時 | 2019-01-10 23:56:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 396 bytes |
コンパイル時間 | 1,452 ms |
コンパイル使用メモリ | 171,892 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 19:37:46 |
合計ジャッジ時間 | 3,289 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 WA * 5 RE * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vector<int> a(n); for(int i = 0; i < m; i++) { cin >> a[i]; } sort(a.begin(), a.end()); int ans = 1 << 30; for(int i = 0; i < m - n; i++) { ans = min(ans, min(abs(a[i]), abs(a[i + n - 1])) + abs(a[i] - a[i + n - 1])); } cout << ans << endl; return 0; }