제출 #1285031

#제출 시각아이디문제언어결과실행 시간메모리
1285031okahak71Money (IZhO17_money)C++20
100 / 100
1116 ms55228 KiB
#pragma GCC optimize("O3,unroll-loops") #include <bits/stdc++.h> #define ll long long #define pb push_back #define ins insert #define pll pair<ll, ll> #define vec vector #define ss second #define ff first using namespace std; const ll inf = 1e17; void _(){ ll n; cin >> n; ll last = 0; vec<ll>a(n + 1, -1); multiset<ll>nw; ll ans = 0; nw.ins(inf); for(ll i = 0; i < n; i++) cin >> a[i]; for(ll i = 1; i <= n; i++){ if(a[i - 1] > a[i]){ while(last < i){ ll up = *nw.upper_bound(a[last]); while(*nw.lower_bound(a[last]) <= up and last < i) nw.ins(a[last++]); ans++; } } } cout << ans; } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); _(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...