結果

問題 No.370 道路の掃除
ユーザー GrayCoder
提出日時 2018-09-17 14:32:50
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 554 bytes
コンパイル時間 1,292 ms
コンパイル使用メモリ 167,328 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-18 07:39:52
合計ジャッジ時間 2,337 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 = 10000;
  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;
}
0