#include "bits/stdc++.h"
using namespace std;
#define int long long
#define vec vector
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
using pii = pair<int, int>;
signed main() {
int n; cin >> n;
pii start, end;
cin >> start.X >> start.Y >> end.X >> end.Y;
vec<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (start == end) {
cout << 0 << endl;
return 0;
}
if (n == 2) {
int ans;
if (end.X == 2) {
ans = 1;
} else if (start.X == 2) {
ans = min(end.Y, abs(end.Y - (a[0] + 1)) + 1);
} else {
ans = min(
min(end.Y, abs(end.Y - (a[0] + 1)) + 1) + 1,
abs(end.Y - start.Y)
);
}
cout << ans << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |