#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll all_nums[1000001];
int main(){
ll n,seg_count=1;
cin>>n;
cin>>all_nums[0];
for(ll i=1;i<n;i++){
cin>>all_nums[i];
}
set<ll> segments_taken;
segments_taken.insert(all_nums[0]);
ll largest_note=1000001;
for(ll i=1;i<n;i++){
while(all_nums[i]<=largest_note and all_nums[i]>=all_nums[i-1] and i<n){
segments_taken.insert(all_nums[i]);
largest_note=*segments_taken.upper_bound(all_nums[i]);
i++;
}
if(i!=n){
seg_count++;
segments_taken.insert(all_nums[i]);
largest_note=*segments_taken.upper_bound(all_nums[i]);
}
}
cout<<seg_count<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |