結果
問題 |
No.370 道路の掃除
|
ユーザー |
![]() |
提出日時 | 2018-02-22 17:21:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 768 bytes |
コンパイル時間 | 690 ms |
コンパイル使用メモリ | 85,848 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-01 21:08:31 |
合計ジャッジ時間 | 1,635 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 4 |
ソースコード
#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<long long> V(M); for ( int i = 0; i < M; i++ ) { cin >> V[i]; } long long ans = LLONG_MAX; for ( int i = 0; i <= M-N; i++ ) { long long 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; }