제출 #1164576

#제출 시각아이디문제언어결과실행 시간메모리
1164576PwoMoney (IZhO17_money)C++20
100 / 100
793 ms51320 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, a[1000005];
set<int> st;

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	st.insert(1e9);
    int ans = 0;
    int l = 1;
    while (l <= n) {
        int x = *st.upper_bound(a[l]);
        int r = l + 1;
        while (r <= n && a[r] >= a[r - 1] && a[r] <= x)
            r++;
        ans++;
        for (int k = l; k < r; k++)
            st.insert(a[k]);
        l = r;
    }
	
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...