Submission #142868

#TimeUsernameProblemLanguageResultExecution timeMemory
142868vardan__02Money (IZhO17_money)C++14
100 / 100
1387 ms62088 KiB
#include <iostream> #include <fstream> #include <algorithm> #include <cstring> #include <string> #include <vector> #include <cstdio> #include <queue> #include <deque> #include <stack> #include <cmath> #include <list> #include <set> #include <map> using namespace std; typedef long long ll; #define MP make_pair #define PB push_back ll n,m,i,j,k,p,a[1000005],ans,u,v,t,q; set<ll> s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for(i=1;i<=n;i++) cin>>a[i]; ans=1; for(i=1;i<=n;i++) { if(a[i]>=a[i-1]) s.insert(a[i]); else break; } for(;i<=n;i++) { ans++; set<ll>::iterator it=s.upper_bound(a[i]); if(it==s.end()) { s.insert(a[i]); i++; while(i<=n && a[i]>=a[i-1]) { s.insert(a[i]); i++; } i--; } else { u=*it; s.insert(a[i]); i++; while(i<=n && a[i]>=a[i-1] && a[i]<=u) { s.insert(a[i]); i++; } i--; } } cout<<ans<<endl; 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...