1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
using namespace std;
int t[50007];
int main() {
	int c, b = 0;
	cin >> c;
	for (int i = 0; i<c; i++){
		cin >> t[i];
	}
	if (c%2 == 0){
	for (int i = 0; i<c; i = i+2){
		
		if (t[i+1] >= t[i]){
			b = b+1;
			if (t[i] > t[i+2]){
				t[i+1] = t[i+2] - 1;
			}
			else {
				t[i+1] = t[i] - 1;
			}
		}
		
	}
	}
	else {
			for (int i = 0; i<c; i = i+2){
		
		if (t[i+1] >= t[i]){
			b = b+1;
			if (t[i] > t[i+2]){
				t[i+1] = t[i+2] - 1;
			}
			else {
				t[i+1] = t[i] - 1;
			}
		}
		
	}
	if (t[c-1] < t[c-2]){
		b=b+1;
	}
	}
	cout << b;
	return 0;
}