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 "sequence.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;
using ii = pair <ll, ll>;
using vii = vector <ii>;
int sequence (int n, vi ve) {
for (int &i : ve) i--;
vi v2 = ve;
sort(v2.begin(), v2.end());
ll med = v2[(n-1)/2];
ll ans = 0;
vll freq(n, 0);
for (int i : ve) freq[i]++;
for (ll i = med; i < n; i++) {
ans = max(ans, freq[i]);
}
freq.assign(n, 0);
ll i = 0;
for (; i < n; i++) {
if (!i || ve[i-1] <= ve[i]) {
ans = max(ans, ++freq[ve[i]]);
} else break;
}
freq.assign(n, 0);
for (; i < n; i++) {
if (!i || ve[i-1] >= ve[i]) {
ans = max(ans, ++freq[ve[i]]);
} else break;
}
return int(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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |