#include <bits/stdc++.h>
using namespace std;
int n, m;
set <int> sor;
int check(int l, int r) {
if(sor.upper_bound(l) == sor.end() || *sor.upper_bound(l)>=r){
return 0;
}
else{
return 1;
}
}
int main(){
cin >> n;
int a[n+10];
for(int i=0; i<n; i++){
cin >> a[i];
}
int ans=0;
for(int i=0; i<n; i++){//segmentis dasawyisi
int st = i;
ans++;
while (i != n - 1 && a[i] <= a[i + 1] && check(a[st], a[i + 1]) == 0) i++;
for(int j=st; j<=i; j++){
sor.insert(a[i]);
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |