This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
using namespace std;
#include <bits/stdc++.h>
#define int long long
int32_t main()
{
int n;
int sx,sy,ex,ey;
cin>>n;
cin>>sy>>sx>>ey>>ex;
vector<int> l(n);
for(int i=0;i<n;i++)
cin>>l[i];
int ans=0;
if(sy==ey){
ans+=min(min(abs(sx-ex),sx+l[0]+1-ex+1),l[0]+1-sx+ex+1);
}
if(sy<ey){
ans+=min(min(abs(sx-ex),sx+l[0]+1-ex+1),l[0]+1-sx+ex-1);
ans+=abs(sy-ey);
}
if(sy>ey){
ans+=min(min(abs(sx-ex),sx+l[0]+1-ex-1),l[0]+1-sx+ex+1);
ans+=abs(sy-ey);
}
cout<<ans;
return 0;
}
# | 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... |