Submission #1053545

# Submission time Handle Problem Language Result Execution time Memory
1053545 2024-08-11T13:05:13 Z beaconmc Text editor (CEOI24_editor) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
 
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)

using namespace std;

const ll INF = 100000000000000000;
int main(){
	ll n;
	cin >> n;
	vector<ll> arr(n);
	ll a,b;
	ll x,y;

	cin >> a >> b >> x >> y;
	a--;b--;x--;y--;
	FOR(i,0,n) cin >> arr[i];
	ll ans = INF;

	ans = abs(a-x) + abs(b-y);

	if (a != 0){
		ll A,B;
		ll temp = 0;
		temp += abs(b-0);
		temp += 1;
		A = a-1;
		B = arr[A];
		ans = min(ans, temp + abs(A-x) + abs(B-y));
	}
	if (a != n-1){
		ll A,B;
		ll temp = 0;
		temp += abs(b-arr[a]);
		temp += 1;
		A = a+1;
		B = arr[A];
		ans = min(ans, temp + abs(A-x) + abs(B-y));
	}
	ll A,B;
	ll temp = 0;
	temp += abs(a-(n-1));
	cout << temp << endl;

	A = n-1;
	B = 0;
	ans = min(ans, temp + abs(A-x) + abs(B-y));

	cout << ans << endl;




}
















# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -