이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int x1,y1,x2,y2;
cin >> x1 >> y1 >> x2 >> y2;
int so = abs(x1 - x2);
int arr[n];
for(int i = 0; i < n; i++){
cin >> arr[i];
}
if(x2 == n){
cout << so << endl;
}else{
if(x1 == n){
y1 = 0;
}
int ro = arr[0] + 1;
int dist1 = abs(y2 - y1);
int dist2 = ro - dist1;
int res1 = so + min(dist1, dist2);
if(x1 == n){
cout << res1 << endl;
}else{
so = n - x1;
x1 = n;
so = so + abs(x2 - x1);
y1 = 0;
dist1 = abs(y2 - y1);
dist2 = ro - dist1;
int res2 = so + min(dist1,dist2);
cout << min(res1, res2);
}
}
}
# | 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... |