Submission #758363

#TimeUsernameProblemLanguageResultExecution timeMemory
758363haxormanMoney (IZhO17_money)C++14
100 / 100
1108 ms51408 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 1e6 + 7; int arr[mxN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < n; ++i) { cin >> arr[i]; } arr[n] = INT_MIN; int ans = 0; set<int> vals; set<int>::iterator it = vals.end(); for (int i = 1; i <= n; ++i) { vals.insert(arr[i - 1]); if (arr[i - 1] > arr[i] || (it != vals.end() && *it < arr[i])) { ++ans; it = vals.upper_bound(arr[i]); } } 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...