#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;
#define all(x) x.begin(), x.end()
#define pb push_back
#define ar array
#define nl '\n'
#include "sequence.h"
// #include "grader.cpp"
using ordered_set = tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>;
int sequence(int n, std::vector<int> a) {
int ans = 0;
for(int i = 0; i < n; i++) {
ordered_set st;
vector<int> cnt(n + 1);
for(int j = i; j < n; j++) {
cnt[a[j]]++;
st.insert({a[j], j});
int val = st.find_by_order(st.size() / 2) -> first;
ans = max(ans, cnt[val]);
if(st.size() % 2 == 0) {
val = st.find_by_order(st.size() / 2 - 1) -> first;
ans = max(ans, cnt[val]);
}
}
}
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... |