Submission #886240

# Submission time Handle Problem Language Result Execution time Memory
886240 2023-12-11T15:35:12 Z vjudge1 Airplane (NOI23_airplane) C++17
22 / 100
70 ms 22768 KB
#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define sp " "
#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second
#define pb push_back
#define N 300005
#define int long long

const int INF = 2e18 + 7;

int d[2][N];
vector<int> adj[N];
int arr[N];

int32_t main(){
	//fileio();
	fastio();

	int n, m;
	cin>>n>>m;
	int maks = 0;
	for (int i = 1; i <= n; i++){
		cin>>arr[i];
		maks = max(maks, arr[i]);
	}
	
	for (int i = 1; i <= m; i++){
		int u, v;
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	d[0][1] = 0;
	for (int i = 2; i <= n; i++){
		d[0][i] = max(arr[i], d[0][i - 1] + 1);
	}

	d[1][n] = 0;
	for (int i = n - 1; i >= 1; i--){
		d[1][i] = max(arr[i], d[1][i + 1] + 1);
	}

	int ans = INF;
	for (int i = 1; i <= n; i++){
		if (arr[i] == maks) ans = min(ans, d[0][i] + d[1][i]);
	}
	
		
	cout<<ans<<endl;
	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 54 ms 21876 KB Output is correct
3 Correct 55 ms 22100 KB Output is correct
4 Correct 54 ms 22096 KB Output is correct
5 Correct 59 ms 22768 KB Output is correct
6 Correct 70 ms 22608 KB Output is correct
7 Correct 55 ms 22608 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10584 KB Output is correct
2 Incorrect 2 ms 10588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10584 KB Output is correct
2 Incorrect 2 ms 10588 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 10588 KB Output is correct
2 Correct 54 ms 21876 KB Output is correct
3 Correct 55 ms 22100 KB Output is correct
4 Correct 54 ms 22096 KB Output is correct
5 Correct 59 ms 22768 KB Output is correct
6 Correct 70 ms 22608 KB Output is correct
7 Correct 55 ms 22608 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 2 ms 10584 KB Output is correct
10 Incorrect 2 ms 10588 KB Output isn't correct
11 Halted 0 ms 0 KB -