#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, a[1000005];
set<int> st;
int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
st.insert(n + 1);
int ans = 1; int j = 1, cur = *st.upper_bound(a[j]);
while (j <= n) {
int v = *st.upper_bound(a[j]);
if (a[j] < a[j - 1] || v != cur) {
cur = v;
ans++;
}
st.insert(a[j]);
j++;
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |