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;
const int MX=1e6+10;
int a[MX];
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
set < int > st;
st.insert(MX);
int bgz=MX;
int ans=1;
for(int i=2;i<=n;i++)
{
st.insert(a[i]);
if(a[i-1]>a[i] || a[i]>bgz)
{
ans++;
bgz=(*st.upper_bound(a[i]));
}
}
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... |