제출 #1284025

#제출 시각아이디문제언어결과실행 시간메모리
1284025okahak71Money (IZhO17_money)C++20
0 / 100
1 ms572 KiB
#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]){ //cout << a[i - 1] << ' ' << a[i] << endl; while(last < i){ ll up = *nw.lower_bound(a[last]); while(*nw.lower_bound(a[last]) == up and last < i) nw.ins(a[last++]); //cout << *nw.upper_bound(a[last]) << ' ' << up << ' ' << last << endl; ans++; } } } cout << ans << endl; //for(ll i : nw) cout << i << ' '; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); _(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...