Submission #886139

# Submission time Handle Problem Language Result Execution time Memory
886139 2023-12-11T13:42:34 Z vjudge1 Airplane (NOI23_airplane) C++17
0 / 100
123 ms 14288 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
constexpr int INF = LONG_LONG_MAX;
int32_t main(){
	int n,m;cin>>n>>m;
	vector<int> arr(n);
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}
	vector<vector<int>> tree(n);
	for (int i = 0; i < m; i++){
		int u,v;cin>>u>>v;
		tree[u-1].push_back(v-1);
		tree[v-1].push_back(u-1);
	}
	vector<int> suff = arr;
	for (int i = n-2; i >= 0; i--){
		suff[i]=max(suff[i+1],suff[i]);
	}
	int crrh = 0;
	int ans = 0;
	bool dusuoz = false;
	for (int i = 0; i < n-1; i++){
		if (suff[i+1]<arr[i]){
			dusuoz=true;
			//lets fucking go dusuoz
		}
		if (dusuoz){
			if (crrh>suff[i+1]){
				ans+=max(1ll,crrh-suff[i+1]);
				crrh=suff[i+1];
			}
			else {
				ans++;
			}
		}
		else {
			if (crrh<arr[i+1]){
				ans+=max(1ll,arr[i+1]-crrh);
				crrh=arr[i+1];
			}
			else {
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 123 ms 14288 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 123 ms 14288 KB Output isn't correct
3 Halted 0 ms 0 KB -