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 <iostream>
#include <set>
using namespace std;
int N;
int A[1000006];
set<int> S;
int ans;
int main(){
cin>>N;
for(int i=0;i<N;i++)
cin>>A[i];
S.insert(N+1);
for(int i=0;i<N-1;i++){
//cout<<A[i]<<" ";
if((A[i]>A[i+1]) or (A[i]<A[i+1] and *S.lower_bound(A[i])<A[i+1])){
ans++;
//cout<<"| ";
}
S.insert(A[i]);
}
//cout<<A[N-1]<<endl;
cout<<ans+1;
}
# | 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... |