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,d; cin >> n >> d;
vector<int> v(n); for (int &i : v) cin >> i;
vector<int> activate(n);
stack<int> q;
for (int i = 0; i<n; ++i) {
while (!q.empty() && v[q.top()] < v[i]) q.pop();
if (!q.empty())
++activate[q.top()];
q.push(i);
}
int cur = 0, ans = 1;
for (int i = n-1; i+1; --i) {
cur -= activate[i]-1;
ans = max(ans, cur);
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |