#include <bits/stdc++.h>
using namespace std;
int n;
set<int> sim;
int ans = 0;
int arr[1000005];
int main(){
cin >> n;
for(int i=1;i<n;i++){
cin >> arr[i];
}
int batas = 1000000000;
for(int i=1;i<=n;i++){
if(i != 1 && (arr[i] < arr[i-1] || arr[i] > batas)){
ans++;
set<int>::iterator it = sim.upper_bound(arr[i]);
if(it == sim.end()){
batas = 1000000000;
}else{
batas = *it;
}
}
sim.insert(arr[i]);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |