Submission #886163

# Submission time Handle Problem Language Result Execution time Memory
886163 2023-12-11T14:14:49 Z vjudge1 Airplane (NOI23_airplane) C++17
0 / 100
108 ms 3544 KB
#include <bits/stdc++.h>
using namespace std;

#define int int64_t

int32_t main() {
	int n, m;
	cin>>n>>m;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin>>a[i];
	for(int i=0; i<m; i++) {
		int tmp;
		cin>>tmp>>tmp;
	}
	int cur = 0, ans = 0;
	vector<int> sufmax(n);
	sufmax[n-1] = a[n-1];
	for(int i=n-2; i>0; i--) sufmax[i] = max(sufmax[i+1], a[i]);
	for(int i=0; i<n-1; i++) {
		if(cur + 1 < a[i+1]) {
			ans += a[i+1]-1-cur;
			cur += a[i+1]-1-cur;
		}
		if(sufmax[i] > cur) {
			cur++;
			ans++;
		}
		else if(sufmax[i] < cur) {
			cur--;
			ans++;
		}
		else ans++;
	}
	ans += max(1l, cur);
	cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 108 ms 3544 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 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 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 108 ms 3544 KB Output isn't correct
3 Halted 0 ms 0 KB -