This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
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;
s.insert(-a[0]);
int cnt = 1;
for(int i = 1; i < n; i++) {
auto it = s.lower_bound(-a[i]);
auto jt = s.upper_bound(-a[i]);
if(it == s.end()) {
cnt++;
}
else if((*it) == -a[i - 1]) {
}
else if((*jt) == -a[i - 1]) {
}
else {
cnt++;
}
s.insert(-a[i]);
}
cout << cnt << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |