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 <vector>
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <climits>
using namespace std;
int sequence(int N, vector<int> A) {
int maxOccurrences = 0;
for (int l = 0; l < N; ++l) {
vector<int> freq(N + 1, 0);
vector<int> subarray;
for (int r = l; r < N; ++r) {
subarray.push_back(A[r]);
freq[A[r]]++;
vector<int> temp = subarray;
sort(temp.begin(), temp.end());
int k = temp.size();
int median1 = temp[(k - 1) / 2];
int median2 = temp[k / 2];
maxOccurrences = max(maxOccurrences, freq[median1]);
if (median1 != median2) {
maxOccurrences = max(maxOccurrences, freq[median2]);
}
}
}
return maxOccurrences;
}
# | 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... |