This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(),a.end()
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
set <int> st;
st.insert(2e9);
int ans = 0;
for (int i = 0; i < n; i++) {
int val = *st.upper_bound(a[i]);
st.insert(a[i]);
while(a[i + 1] >= a[i] && a[i + 1] <= val && i + 1 < n){
i++;
st.insert(a[i]);
}
ans++;
}
cout << ans << '\n';
return 0;
}
# | 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... |