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
#include <bits/stdc++.h>
using namespace std;

int lic(vector<int> v, int s = 1)
{
    int wyn = 0;
    for (int i = 1; i < v.size(); i++)
    {
        if (v[i] * s <= v[i - 1] * s)
        {
            v[i] = 100000000 * s;
            wyn++;
        }
        s *= -1;
    }
    return wyn;
}

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> pt(n);
    for (int i = 0; i < n; i++)
    {
        cin >> pt[i];
    }
    cout << min(lic(pt), lic(pt, -1)) << '\n';
}