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() {
cin.tie(nullptr)->sync_with_stdio(false);
int N;
cin >> N;
vector<int> a(N);
for (int &value : a) {
cin >> value;
}
set<int> S;
int answer = 1;
for (int i = 1; i < N; i++) {
if (a[i] < a[i - 1]) {
answer++;
} else {
auto it = S.lower_bound(a[i - 1]);
answer += it != S.end() && *it <= a[i];
}
S.insert(a[i - 1]);
}
cout << answer << "\n";
}
# | 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... |