Submission #886240

#TimeUsernameProblemLanguageResultExecution timeMemory
886240vjudge1Airplane (NOI23_airplane)C++17
22 / 100
70 ms22768 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...