Untitled
unknown
c_cpp
a year ago
511 B
9
Indexable
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<int> a(n), pos(n + 1);
for (int i = 0; i < n; i++) cin >> a[i], pos[a[i]] = i + 1;
int cnt = 0;
for (int i = 1; i <= n; i++) {
while (i + 1 <= n && pos[i] < pos[i + 1]) i++;
cnt++;
}
for (int i = 0; i < 64; i++) {
if ((1LL << i) >= cnt) return cout << i << endl, 0;
}
assert(false);
}Editor is loading...
Leave a Comment