제출 #1134353

#제출 시각아이디문제언어결과실행 시간메모리
1134353Alihan_8Text editor (CEOI24_editor)C++20
0 / 100
0 ms396 KiB
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
#define size(x) (int)(x).size()
#define int long long

typedef pair <int,int> pii;

using i64 = long long;

template <class F, class _S>
bool chmin(F &u, const _S &v){
	bool flag = false;
	if ( u > v ){
		u = v; flag |= true;
	}
	return flag;
}

template <class F, class _S>
bool chmax(F &u, const _S &v){
	bool flag = false;
	if ( u < v ){
		u = v; flag |= true;
	}
	return flag;
}

const int inf = 1e16;

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
    
	int n, sx, sy, ex, ey;
	cin >> n >> sx >> sy >> ex >> ey;
    
    --sx, --sy, --ex, --ey;
    
    if ( sx > ex ) swap(sx, ex), swap(sy, ey);
    
	vector <int> l(n);
    
	for ( int i = 0; i < n; i++ ){
		cin >> l[i]; ++l[i];
	}
	
	if ( n == 1 ) return cout << "0\n", 0;
	
	int opt = abs(ey - sy);
	
	chmin(opt, sy + l[0] - ey + 1);
	chmin(opt, l[0] - sy + ey + 1);
	
	cout << opt + ex - sx;
	
	cout << '\n';
}
#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...