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>
#define MAXN 1000010
using namespace std;
int n, a[MAXN], ress;
int main() {
cin>>n;
for (int i=0; i<n; i++) cin>>a[i];
set<int> s;
int i=0;
while (i<n)
{
auto it=s.upper_bound(a[i]);
bool nema=0; int br;
if (it==s.end()) nema=1;
else br=*it;
i++;
while (i<n && (i==0 || a[i]>=a[i-1]) && (nema || a[i]<=br)) { s.insert(a[i]); i++; }
//cout<<i<<endl;
ress++;
}
cout<<ress;
}
# | 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... |