# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1128714 | BilAktauAlmansur | Money (IZhO17_money) | C++20 | 1 ms | 328 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;
for(int i = 1; i <= n;) {
auto it = st.lower_bound(a[i]);
int last = i;
for(int j = i + 1; j <= n; j++) {
if(a[j] < a[j - 1])break;
auto ii = st.lower_bound(a[j]);
if(ii != it)break;
last = j;
}
for(int j = i; j <= last; j++)st.insert(a[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();
}
컴파일 시 표준 에러 (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... |