Submission #683890

#TimeUsernameProblemLanguageResultExecution timeMemory
683890onlk97Money (IZhO17_money)C++14
0 / 100
1 ms320 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; int a[n+1]; for (int i=1; i<=n; i++) cin>>a[i]; int wh=n+1; for (int i=2; i<=n; i++){ if (a[i-1]>a[i]){ wh=i; break; } } int ans=1; set <int> s; for (int i=1; i<wh; i++) s.insert(a[i]); for (int i=wh; i<=n; i++){ auto it=s.lower_bound(a[i]+1); int mx; if (it==s.end()) mx=1e9; else mx=(*it); ans++; bool ok=0; for (int j=i+1; j<=n; j++){ if (a[j-1]>a[j]||a[j]>mx){ i=j-1; ok=1; break; } } if (!ok) break; } cout<<ans<<'\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...