Submission #169162

#TimeUsernameProblemLanguageResultExecution timeMemory
169162tselmegkhMoney (IZhO17_money)C++14
0 / 100
2 ms376 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n; cin >> n; vector<int> a(n); int ans = 1; for(int i = 0; i < n; i++){ cin >> a[i]; } int j = 1; multiset<int> ms; while(a[j] >= a[j - 1] && j < n){ ms.insert(a[j]); j++; } int cnt = 0, bound = 0; while(j < n){ if(cnt == 0){ ans++; auto it = ms.upper_bound(a[j]); if(it != ms.end()){ bound = *it; }else{ bound = 1e9; } ms.insert(a[j]); cnt++; j++; }else{ if(a[j] < a[j - 1]){ cnt = 0; continue; }else{ if(a[j] <= bound){ ms.insert(a[j]); cnt++; j++; }else{ cnt = 0; } } } } 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...