結果
問題 |
No.370 道路の掃除
|
ユーザー |
|
提出日時 | 2018-09-17 14:42:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 554 bytes |
コンパイル時間 | 1,674 ms |
コンパイル使用メモリ | 167,052 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 07:40:00 |
合計ジャッジ時間 | 2,114 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define sorted(a) sort(a.begin(), a.end()); typedef long long ll; const long mod = 1e9 + 7; int main(void) { #ifdef DEBUG freopen("input.txt", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); int N, M; cin >> N >> M; int D[1000]; for (int i = 0; i < M; i++) cin >> D[i]; int dist; int ans = 65535; for (int i = 0; i + N <= M; i++) { dist = D[i+N-1] - D[i] + min(abs(D[i]), abs(D[i+N-1])); ans = min(ans, dist); } cout << ans << endl; return 0; }