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
#include<cstdio>

int main() {
	int n;
	scanf("%d\n", &n);

	int current;
	int last;
	bool skip1 = true;
	bool skip2 = true;

	int result1 = 0;
	int result2 = 0;

	for (int i = 0; i < n; i++) {
		scanf("%d", &current);

		if (skip1) {
			skip1 = false;
		} else {
			if ((i % 2 == 1 && current >= last) || (i % 2 == 0 && current <= last)) {
				result1++;
				skip1 = true;
			}
		}

		if (skip2) {
			skip2 = false;
		} else {
			if ((i % 2 == 1 && current <= last) || (i % 2 == 0 && current >= last)) {
				result2++;
				skip2 = true;
			}
		}

		last = current;
	}

	printf("%d\n", result1 < result2 ? result1 : result2);

	return 0;
}