結果

問題 No.370 道路の掃除
ユーザー tetsuzuki1115
提出日時 2018-02-22 17:17:58
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 748 bytes
コンパイル時間 1,027 ms
コンパイル使用メモリ 86,124 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-10-01 21:07:28
合計ジャッジ時間 2,004 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N,M;
    cin >> N >> M;
    vector<int> V(M);
    for ( int i = 0; i < M; i++ ) {
        cin >> V[i];
    }
    int ans = INT_MAX;
    for ( int i = 0; i <= M-N; i++ ) {
        int a;
        long long x = V[i]; long long y = V[i+N-1];
        if ( x*y >= 0 ) { a = max( abs(x), abs(y) ); }
        else { a = min(abs(x),abs(y))*2 + max(abs(x),abs(y)); }
        ans = min( ans, a );
    }
    cout << ans << endl;
    return 0;
}
0