답안 #886171

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886171 2023-12-11T14:20:30 Z vjudge1 Airplane (NOI23_airplane) C++17
22 / 100
136 ms 3540 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+1] > cur) {
			cur++;
			ans++;
		}
		else if(sufmax[i+1] < cur) {
			cur--;
			ans++;
		}
		else ans++;
	}
	ans += cur;
	cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 108 ms 3528 KB Output is correct
3 Correct 123 ms 3540 KB Output is correct
4 Correct 132 ms 3408 KB Output is correct
5 Correct 130 ms 3404 KB Output is correct
6 Correct 130 ms 3524 KB Output is correct
7 Correct 136 ms 3520 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 108 ms 3528 KB Output is correct
3 Correct 123 ms 3540 KB Output is correct
4 Correct 132 ms 3408 KB Output is correct
5 Correct 130 ms 3404 KB Output is correct
6 Correct 130 ms 3524 KB Output is correct
7 Correct 136 ms 3520 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -