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 pb push_back
#define mp make_pair
#define ll long long
#define int long long
#define itr iterator
typedef pair<ll,ll> pii;
const ll MAX=2e6;
const ll INF=1e12;
set<int> st;
set<int> ::itr it;
int N,res,arr[MAX];
signed main()
{
ios_base::sync_with_stdio(false);
cin>>N;
for(int A=1;A<=N;A++)
cin>>arr[A];
st.insert(0);
st.insert(MAX);
for(int A=1;A<=N;)
{
res++;
it=st.upper_bound(arr[A]);
while(A<=N)
{
st.insert(arr[A]);
if(arr[A+1]>=arr[A] and arr[A+1]<=*it)
A++;
else
break;
}
A++;
}
cout<<res;
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... |