#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n;
cin >> n;
vector<int> a(n);
int ans = 1;
for(int i = 0; i < n; i++){
cin >> a[i];
}
int j = 1;
multiset<int> ms;
while(a[j] >= a[j - 1] && j < n){
ms.insert(a[j]);
j++;
}
int cnt = 0, bound = 0;
while(j < n){
if(cnt == 0){
ans++;
auto it = ms.upper_bound(a[j]);
if(it != ms.end()){
bound = *it;
}else{
bound = 1e9;
}
ms.insert(a[j]);
cnt++;
j++;
}else{
if(a[j] < a[j - 1]){
cnt = 0;
continue;
}else{
if(a[j] <= bound){
ms.insert(a[j]);
cnt++;
j++;
}else{
cnt = 0;
}
}
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |