Submission #916298

#TimeUsernameProblemLanguageResultExecution timeMemory
916298cotMoney (IZhO17_money)C++14
0 / 100
1 ms440 KiB
#include <iostream> #include <algorithm> #include <climits> #include <array> #include <map> #include <set> #define int long long #define ff first #define ss second #define all(x) x.begin(),x.end(); #define pb push_back #define pp pop_back #define r0 return 0 using namespace std; const int N = 2 * 1e6 + 5; int n,m,l; int a[N],mn,ans, st; set <int> s; bool araferi(int l,int r){ if(s.upper_bound(l) != s.end() && *s.upper_bound(l) < r) return false; else return true; } signed main(){ cin >> n; for (int i = 1; i <= n; i++){ cin >> a[i]; } for (int k = 1; k <= n; k++) { mn = a[k]; ans++; st = k; while(a[k] < a[k + 1] && araferi(mn, a[k + 1])){ k++; } for (int i = st; i <= k; i++) { s.insert(a[i]); } } cout << ans; cout << endl; r0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...