#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
int N;
cin >> N;
int A[N];
for(int i=0;i<N;i++) cin >> A[i];
set<int> S;
queue<int> Q;
int prev=-1;
int cnt=1;
int lessthan=1e8;
for(int i=0;i<N;i++){
if(prev==-1){
prev=A[i];
auto k=S.upper_bound(A[i]);
if(k!=S.end()){
lessthan=*k;
}
continue;
}
if(A[i]>=A[i-1]&&A[i]<=lessthan)continue;
prev=-1;
cnt++;
i--;
}
cout << cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |