結果

問題 No.370 道路の掃除
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2016-05-13 23:30:50
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,346 bytes
コンパイル時間 890 ms
コンパイル使用メモリ 90,140 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 17:10:08
合計ジャッジ時間 1,986 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 3 ms
6,944 KB
testcase_22 AC 3 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 3 ms
6,940 KB
testcase_33 AC 4 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
 
#define MOD 1000000007

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> v;
  rep(i,0,m){
    int a;
    cin>>a;
    v.pb(a);
  }
  int ans = 1000000000;
  rep(i,0,n+1){
    int c1  = 0;
    int c2 = 0;
    int index = 0;
    int mx = 0;
    int mn = 0;
    while(1){
      if(c1==i)break;
      if(index==m)break;
      if(v[index]>=0){
        c1++;
        mx = max(mx,v[index]);
      }
      index++;
    }
    index = m-1;
    while(1){
      if(c2==n-i)break;
      if(index==-1)break;
      if(v[index]<0){
        c2++;
        mn = min(mn,v[index]);
      }
      index--;
    }
    if(c1==i&&c2==n-i){
      ans = min(ans,mx*2-mn);
      ans = min(ans,mx-mn*2);
    }
  }
  cout << ans << endl;
  return 0;
}
0