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>
#define SZ(s) ((int) ((s).size()))
using namespace std;
vector<int> medians(const vector<int> values) {
int n = SZ(values);
assert(n > 0);
if (n % 2 == 0) {
return {values[n/2 - 1], values[n / 2]};
} else {
return {values[n/2]};
}
}
int sub1(const vector<int>& a) {
int n = SZ(a);
int res = 0;
for (int l = 0; l < n; ++l) {
for (int r = l; r < n; ++r) {
vector<int> b(a.begin() + l, a.begin() + r + 1);
unordered_map<int, int> cnt;
for (int val : b) cnt[val] += 1;
sort(b.begin(), b.end());
auto meds = medians(b);
for (int med : meds) {
res = max(res, cnt[med]);
}
}
}
return res;
}
int sequence(int n, std::vector<int> a) {
if (n <= 100) return sub1(a);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |