Submission #156175

#TimeUsernameProblemLanguageResultExecution timeMemory
156175theboatmanMoney (IZhO17_money)C++17
0 / 100
2 ms256 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++) { //cout << a[i] << " " << *bank.begin() << " " << *--bank.end() << "\n"; if (a[i] >= *--bank.end()) { int x = a[i]; while(i < n && x <= a[i]) { x = a[i]; bank.insert(x); i++; } i--; } else { vector <int> lazy; if (a[i] < *bank.begin()) { int x = a[i]; while(i < n && x <= a[i] && a[i] <= *bank.begin()) { x = a[i]; lazy.push_back(x); i++; } i--; } else { int x = a[i]; while(i < n && x <= a[i] && a[i] <= *--bank.end()) { x = a[i]; lazy.push_back(x); i++; } i--; } for(auto it : lazy) { bank.insert(it); } } ans++; } cout << ans + 1 << "\n"; return 0; } /* 3 5 1 2 2 2 2 2 2 3 5 1 2 4 4 4 4 4 4 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...