제출 #1134438

#제출 시각아이디문제언어결과실행 시간메모리
1134438AgageldiMoney (IZhO17_money)C++17
45 / 100
10 ms1864 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 200005 #define pb push_back #define ff first #define ss second #define sz(s) (int)s.size() ll n, t, ind, a[N], b[N], gr; set <int> nw; deque <int> v; int main () { ios::sync_with_stdio(0);cin.tie(0); cin >> n; bool tr = 0; for(int i = 1; i <= n; i++) { cin >> a[i]; if(i == 1 || !tr && a[i] >= a[i-1]) { nw.insert(a[i]); ind = i + 1; continue; } tr = 1; } gr = 1; if(ind == n + 1) { cout << gr << '\n'; return 0; } for(int i = ind; i <= n; i++) { if(sz(v) && v[sz(v) - 1] <= a[i]) { v.pb(a[i]); continue; } while(sz(v) > 0) { auto p = nw.upper_bound(v[0]); if(p == nw.end()) { while(sz(v) > 0) { nw.insert(v[0]); v.pop_front(); } gr++; break; } gr++; while(sz(v) > 0 && v[0] <= *p) { nw.insert(v[0]); v.pop_front(); } } v.pb(a[i]); } while(sz(v) > 0) { auto p = nw.upper_bound(v[0]); if(p == nw.end()) { while(sz(v) > 0) { nw.insert(v[0]); v.pop_front(); } gr++; break; } gr++; while(sz(v) > 0 && v[0] <= *p) { nw.insert(v[0]); v.pop_front(); } } cout << gr << '\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...