제출 #1113298

#제출 시각아이디문제언어결과실행 시간메모리
1113298EfeBabagilText editor (CEOI24_editor)C++14
0 / 100
1 ms436 KiB
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]; if(sy>ey) { swap(ey,sy); swap(sx,ex); } int ans=0; if(sy==ey){ ans=abs(sx-ex)+abs(sy-ey); if(sy!=1) { ans=min(ans,sx+l[0]+1-ex+1) ; } if(sy!=n) { ans=min(ans,l[0]+1-sx+1+ex-1+1) ; } if(ey!=n) { ans=min(ans,l[0]+1-ex+1+sx-1+1) ; } if(ey!=1) { ans=min(ans,ex+l[0]+1-sx+1) ; } } if(sy<ey){ ans=abs(sx-ex)+abs(sy-ey); if(sy!=1) { ans=min(ans,sx+l[0]+1-ex-1+abs(sy-ey)+1) ; } if(sy!=n) { ans=min(ans,l[0]+1-sx+1+ex-1+abs(sy-ey)-1) ; } if(ey!=n) { ans=min(ans,l[0]+1-ex+1+sx-1+abs(sy-ey)+1) ; } if(ey!=1) { ans=min(ans,ex+l[0]+1-sx+abs(sy-ey)-1) ; } } cout<<ans; 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...