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;
typedef long long ll;
const int mxN = 1e6+10;
int N, A[mxN], ans;
void solve() {
cin >> N;
for (int i = 0; i < N; i++)
cin >> A[i];
multiset<int> mst;
for (int i = 0; i < N; i++) {
int j = i+1;
auto it = mst.lower_bound(A[i]);
while(j < N && (A[j] >= A[j-1]) && (it == mst.end() || *it >= A[j]))
j++;
for (int ii = i; ii < j; ii++)
mst.insert(A[ii]);
i = j-1;
ans++;
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
solve();
}
# | 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... |