1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <vector>
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> T(n);
    for(auto &v:T)  cin >> v;
    auto calc = [n,&T](int par) {
        int res = 0;
        for(int i=0;i+1<n;i++) {
            if(i%2 == par) {
                if(T[i] >= T[i+1])  res++, i++;
            } else {
                if(T[i] <= T[i+1])  res++, i++;
            }
        }
        return res;
    };
    cout << min(calc(0),calc(1)) << '\n';
    return 0;
}