Submission #1134461

#TimeUsernameProblemLanguageResultExecution timeMemory
1134461saidponText editor (CEOI24_editor)C++17
5 / 100
0 ms328 KiB
#include <bits/stdc++.h> #define nemeshay ios_base::sync_with_stdio(NULL), cin.tie(0), cout.tie(0); #define int long long #define sigma signed #define pb push_back #define fr first #define sc second #define pii pair<int, int> using namespace std; const int N = 1e6 + 2, inf = 1e18 + 7; int a[N]; sigma main() { int n, xs, ys, xf, yf, ans; cin >> n >> xs >> ys >> xf >> yf; if (xf == n) { cout << xf - xs; return 0; } for (int i = 0; i < n; i++) cin >> a[i]; ans = abs(xs - xf) + abs(ys - yf); if (xs > 1) { int cnt = 0; cnt += ys; cnt += abs(xs - 1 - xf) + abs(a[0] + 1 - yf); ans = min(ans, cnt); } if (xs < n) { int cnt = 0; cnt += a[0] + 1 - ys + 1; cnt += abs(xs + 1 - xf) + abs(1 - yf); ans = min(ans, cnt); } if (xs > 1) { int cnt = 1; cnt += a[0] + 1 - ys + 1; cnt += abs(xs - xf) + abs(1 - yf); ans = min(ans, cnt); } if (xs < n) { int cnt = 1; if (xs == n - 1) cnt++; else cnt += ys; cnt += abs(xs - xf) + abs(a[0] + 1 - yf); ans = min(ans, cnt); } cout << ans << endl; }
#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...