제출 #1126620

#제출 시각아이디문제언어결과실행 시간메모리
1126620brover29Money (IZhO17_money)C++20
100 / 100
820 ms55232 KiB
#include <bits/stdc++.h> //qwerty47924692 using namespace std; using ll = long long; const ll N=1e6+29; const string br="617283"; ll n,a[N],ans=1e18; vector<ll>v; set<ll>s; bool cn(vector<ll> &v,ll x=0){ ll mn=v.front(); ll mx=v.back(); auto it=s.lower_bound(mx); if(it==s.begin()){ goto can; } --it; if(mn<*it){ return 0; } can:; if(x==1){ for(ll i:v){ s.insert(i); } } return 1; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; ll ans=1; for(ll i=1;i<=n;i++){ cin>>a[i]; v.push_back(a[i]); if(a[i]<a[i-1]||!cn(v)){ v.pop_back(); cn(v,1); v.clear(); v.push_back(a[i]); ans++; } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...