Submission #1279494

#TimeUsernameProblemLanguageResultExecution timeMemory
1279494muhammad-ahmadAirplane (NOI23_airplane)C++20
0 / 100
31 ms716 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define endl '\n'

signed main(){
	int n, m; cin >> n >> m;
	int alt = 0, ans = n - 1;
	int lst; cin >> lst;
	for (int i = 2; i <= n; i++){
		int x; cin >> x;
		if (x  > alt){
			alt++;
			ans += x - alt;
			alt = x;
		}
	}
	
	cout << ans + alt - 1 << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...