結果
問題 |
No.370 道路の掃除
|
ユーザー |
|
提出日時 | 2022-10-08 16:48:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 648 bytes |
コンパイル時間 | 1,992 ms |
コンパイル使用メモリ | 193,960 KB |
最終ジャッジ日時 | 2025-02-08 00:30:16 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 4 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M; cin >> N >> M; vector<ll> D(M); rep(i,M) cin >> D[i]; ll ans = 2e9; rep(i,M) if(i + N - 1 < M) { // [D[i], D[i + N - 1]] ll L = D[i], R = D[i + N - 1]; if(0 <= L) { ans = min(ans, R); } else if(R <= 0) { ans = min(ans, abs(L)); } else { ans = min(ans, abs(L) + abs(R - L)); ans = min(ans, abs(R) + abs(R - L)); } } cout << ans << endl; }