Submission #169181

#TimeUsernameProblemLanguageResultExecution timeMemory
169181itglMoney (IZhO17_money)C++14
0 / 100
2 ms376 KiB
#include<bits/stdc++.h> #define pb push_back using namespace std; int a[1000005]; multiset <int> ms; int main(){ int n; cin >> n; for(int i=1;i<=n;i++) cin >> a[i]; a[n+1]=-1; int pos=n; for(int i=1;i<=n;i++){ if(a[i+1]>a[i]) ms.insert(a[i]); else{ pos=i+1; ms.insert(a[i]); break; } } ms.insert(1e7+7); int ans=1; a[pos-1]=0; int lim=-1; for(int i=pos;i<=n;i++){ if(a[i]<lim&&a[i-1]<a[i]){ }else{ ans++; lim=*ms.upper_bound(a[i]); //cout << lim << endl; } ms.insert(a[i]); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...