Submission #1068731

#TimeUsernameProblemLanguageResultExecution timeMemory
1068731vjudge1Text editor (CEOI24_editor)C++17
16 / 100
273 ms14944 KiB
#include<bits/stdc++.h> using namespace std; int calc(int x1, int y1, int x2, int y2){ return abs(x2 - x1) + abs (y2 - y1); } int main(){ int n; cin >> n; int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; int arr[n]; for(int i = 0; i < n; i++){ cin >> arr[i]; } if(n == 1){ cout << 0 <<endl; }else{ int res1 = calc(x1,y1,x2,y2); int res2 = 1e9; if(x1 != n){ res2 = (arr[0] + 2) - y1 + calc(x1 + 1, 1, x2, y2); } int res3 = 1e9; if(x1 != 1){ res3 = y1 + calc(x1 - 1, arr[0] + 1, x2, y2); }else{ res3 = 1 + y1 + calc(1, arr[0] + 1, x2, y2); } int res4 = n - x1; res4 = res4 + 1 + min(calc(n - 1, 1, x2, y2), calc(n - 1, arr[0] + 1, x2, y2)); res1 = min(res1, res2); res1 = min(res1, res3); res1 = min(res1, res4); cout << res1; } }
#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...