이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define inf 1e9+1
#define linf 1e18+1
using namespace std;
const int NMAX=1e6+1;
void solve(){
int n;cin>>n;
int a[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
set<int>st;
int l=1;
int r=2;
int cnt=0;
while(r<=n){
int x;
if(st.size()==0)x=inf;
else x=*st.upper_bound(a[l]);
if((a[r]>=a[r-1])&&(x>=a[r])){
r++;
}
else{
cnt++;
for(int i=l;i<r;i++){
st.insert(a[i]);
}
l=r;
r++;
}
}
cnt++;
cout<<cnt<<"\n";
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int test=1;//cin>>test;
while(test--)solve();
}
# | 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... |