Submission #156172

#TimeUsernameProblemLanguageResultExecution timeMemory
156172theboatmanMoney (IZhO17_money)C++17
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define y1 theboatman #define make_struct(args...) {args} using namespace std; int main() { cin.tie(0); ios :: sync_with_stdio(0); int n; cin >> n; vector <int> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } int now = 0, x = 0; while(now < n && x <= a[now]) { x = a[now]; now++; } set <int> bank; for(int i = 0; i < now; i++) { bank.insert(a[i]); } int ans = 0; for(int i = now; i < n; i++) { if (a[i] >= *--bank.end()) { int x = a[i]; while(i < n && x <= a[i]) { x = a[i]; bank.insert(x); i++; } i--; } else { if (a[i] < *bank.begin()) { int x = a[i]; while(i < n && x <= a[i] && a[i] <= *bank.begin()) { x = a[i]; bank.insert(x); i++; } i--; } else { int x = a[i]; while(i < n && x <= a[i] && a[i] <= *--bank.end()) { x = a[i]; bank.insert(x); i++; } i--; } } ans++; } cout << ans << "\n"; return 0; } /* 1 5 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...