# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1128725 | BilAktauAlmansur | Money (IZhO17_money) | C++20 | 849 ms | 55232 KiB |
#include <bits/stdc++.h>
#pragma optimize("g", on)
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
void Freopen () {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
using namespace std;
#define fi first
#define se second
#define int long long
const int N = 1e6 + 7, M = 1e5 + 1, mod = 1e9 + 7;
int n, a[N];
void solve() {
cin>>n;
for(int i = 1; i <= n; i++)cin>>a[i];
multiset<int> st;
int ans = 0;
st.insert(1e9);
for(int i = 1; i <= n;) {
auto it = *st.upper_bound(a[i]);
st.insert(a[i]);
int last = i;
for(int j = i + 1; j <= n; j++) {
if(a[j] < a[j - 1])break;
if(a[j] > it)break;
st.insert(a[j]);
last = j;
}
// cout << i << ' ' << last << '\n';
i = last + 1, ans ++;
}
cout << ans << '\n';
}
signed main() {
// freopen("duty.in", "r", stdin);
// freopen("duty.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
//Freopen();
int T = 1;
// cin>>T;
while(T --)solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |