Submission #858534

#TimeUsernameProblemLanguageResultExecution timeMemory
858534sheldonMoney (IZhO17_money)C++14
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } multiset<int> s; s.insert(1e9); s.insert(a[0]); int start = -1; for (int i = 1; i < n; ++i) { if (a[i - 1] > a[i]) { start = i; break; } s.insert(a[i]); } if (start == -1) { cout << 1; return; } int ans = 1; for (int i = start; i < n; ++i) { auto it = s.upper_bound(a[i]); int j = i + 1; while (j < n && a[j] <= *it && a[j] > a[j - 1]) { s.insert(a[j]); ++j; } s.insert(a[i]); i = j - 1; ++ans; } cout << ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...