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;
#define fi first
#define se second
constexpr int MAXN = 1e6 + 42;
bool isl[MAXN];
int main() {
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<pair<int, int>> V(N);
for (int i = 0; i < N; i++) {
cin >> V[i].fi;
V[i].se = i + 1;
}
sort(V.rbegin(), V.rend());
int res = 0;
int cur = 0;
for (int i = 0; i < N; i++) {
cur++;
isl[V[i].se] = true;
if (isl[V[i].se + 1]) {
cur--;
}
if (isl[V[i].se - 1]) {
cur--;
}
if (i == N - 1 || V[i].fi != V[i + 1].fi) {
res = max(res, cur);
}
}
cout << res << endl;
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |