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;
const int N = 1'000'100;
int n;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
set<int> proceeded;
vector<int> buffer;
int ans = 0;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
if (buffer.empty() || buffer.back() > a || proceeded.lower_bound(buffer.back()) != proceeded.lower_bound(a)) {
for (int c : buffer) {
proceeded.insert(c);
}
buffer.clear();
ans++;
}
buffer.push_back(a);
}
cout << ans;
}
# | 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... |