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 ll = long long;
const int MAX_N = 1e6;
const int INF = (1 << 30);
int a[1 + MAX_N];
std::set<int> s;
int main() {
std::ios_base::sync_with_stdio(0);
std::cin.tie(0);
int n;
std::cin >> n;
for (int i = 1; i <= n; i++) {
std::cin >> a[i];
}
int answer = 0, next = INF;
s.insert(INF);
for (int i = 1; i <= n; i++) {
if (a[i] != a[i - 1]) {
if (i == 1 || a[i - 1] > a[i] || (*s.lower_bound(a[i])) != next) {
answer++;
next = *s.lower_bound(a[i]);
}
s.insert(a[i]);
}
}
std::cout << answer;
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... |