Submission #587867

#TimeUsernameProblemLanguageResultExecution timeMemory
587867MasterTasterMoney (IZhO17_money)C++14
100 / 100
1159 ms58152 KiB
#include <iostream> #include<set> #define MAXN 1000010 using namespace std; int n, a[MAXN], ress; int main() { cin>>n; for (int i=0; i<n; i++) cin>>a[i]; set<int> s; int i=0; while (i<n) { auto it=s.upper_bound(a[i]); bool nema=0; int br; if (it==s.end()) nema=1; else br=*it; s.insert(a[i]); i++; while (i<n && (i==0 || a[i]>=a[i-1]) && (nema || a[i]<=br)) { s.insert(a[i]); i++; } //cout<<i<<endl; ress++; } cout<<ress; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...