fork download
#include<bits/stdc++.h>

using namespace std;

void solve() {
    int n, cnt, pos2;
    cin >> n;
    vector<int> a(n), pos(n + 1), odd, even;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        pos[a[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        if (a[i] & 1) odd.push_back(a[i]);
        else even.push_back(a[i]);
    }
    cnt = 1, pos2 = -1;
    for (int i = 1; i < n; i+=2) {
        if (pos[i] < pos2) cnt++;
        pos2 = pos[i];
    }
    cout << cnt << endl;
    cnt = 1, pos2 = -1;
    for (int i = 2; i <= n; i+=2) {
        if (pos[i] < pos2) cnt++;
        pos2 = pos[i];
    }
    cout << cnt << endl;
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    solve();
}
Success #stdin #stdout 0.01s 5552KB
stdin
Standard input is empty
stdout
1
1