#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update
>;
#define vec vector
int sequence(int N, std::vector<int> A) {
int ans = 0;
for(int i = 0; i < N; i++) {
auto tree = ordered_set<pair<int,int>>();
map<int,int> f;
for(int j = i; j < N; j++) {
tree.insert({A[j], j});
f[A[j]]++;
if (tree.size() % 2 == 0) {
int a = tree.find_by_order(tree.size() / 2 - 1)->first;
int b = tree.find_by_order(tree.size() / 2)->first;
ans = max(ans, f[a]);
ans = max(ans, f[b]);
} else {
int a = tree.find_by_order(tree.size() / 2)->first;
ans = max(ans, f[a]);
}
}
}
return 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... |