Submission #1214250

#TimeUsernameProblemLanguageResultExecution timeMemory
1214250spetrText editor (CEOI24_editor)C++20
0 / 100
1 ms328 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; ll sy, sx, ey, ex; cin >> sy >> sx; cin >> ey >> ex; vector<ll> lines(n); for (ll i = 0; i < n; i++) { cin >> lines[i]; } // zero-indexed ll s_row = sy - 1, s_col = sx - 1; ll e_row = ey - 1, e_col = ex - 1; // vertical moves ll d = abs(s_row - e_row); // find the minimum line length along the vertical path ll lo = min(s_row, e_row), hi = max(s_row, e_row); ll m = lines[lo]; for (ll i = lo + 1; i <= hi; i++) { m = min(m, lines[i]); } // the column after vertical moves is clamped ll c_after = min(s_col, m); // horizontal moves to reach target column ll h = abs(c_after - e_col); cout << (d + h) << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...