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 <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 ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
int sequence(int n, std::vector<int> a) {
int ans = 0;
int pref[n + 1][n + 1];
for(int i = 0;i <= n;i++)pref[0][i] = 0;
for(int i = 0;i < n;i++){
for(int j = 0;j <= n;j++)pref[i + 1][j] = pref[i][j];
pref[i + 1][a[i]]++;
}
for(int i = 0;i < n;i++){
ordered_multiset mst;
for(int j = i;j < n;j++){
mst.insert(a[j]);
set<int> st;
st.insert(*mst.find_by_order((mst.size() - 1) / 2));
st.insert(*mst.find_by_order((mst.size()) / 2));
for(auto k : st){
int cnt = pref[j + 1][k] - pref[i][k];
ans = max(ans,cnt);
}
}
}
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... |