結果
問題 |
No.370 道路の掃除
|
ユーザー |
![]() |
提出日時 | 2017-07-09 00:21:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 873 bytes |
コンパイル時間 | 720 ms |
コンパイル使用メモリ | 81,784 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-06 20:21:15 |
合計ジャッジ時間 | 2,027 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 4 |
ソースコード
#include <iostream> #include <cstdio> #include <cmath> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <algorithm> #define CK(N,A,B) (A<=N&&N<B) #define REP(i,a,b) for(int i=a;i<b;i++) #define RREP(i,a,b) for(int i=(b-1);a<=i;i--) #define F first #define S second #define ll long long const int INF = 1e9; const long long LLINF = 1e15; using namespace std; int N, M, D[1010]; int main(){ cin>>N>>M; REP(i,0,M) cin>>D[i]; int ans = INF; REP(l,0,M-N+1){ int tmp; if(D[l] < 0 && 0 < D[l+N-1]){ tmp = (abs(D[l])+D[l+N-1]) + min(abs(D[l]),D[l+N-1]); }else{ if(D[l+N-1] <= 0) tmp = abs(D[l]); else tmp = D[l+N-1]; } fprintf(stderr, "tmp: %d\n", tmp); ans = min(ans,tmp); } cout<<ans<<endl; return 0; }