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>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class T> using Tree = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#define sz(a) (int)a.size()
#define fi first
#define se second
Tree<pair<int,int>> S;
map<int,int> tot;
int n;
int sequence(int N, vector<int> a) {
n = N; int ans = 1;
for(int i = 0; i < n; i++){
S.clear(); tot.clear();
for(int j = i; j < n; j++){
S.insert({a[j],j}); tot[a[j]]++;
if(j==i)continue;
int m1 = S.find_by_order((sz(S)-1)/2)->fi;
int m2 = S.find_by_order(sz(S)/2)->fi;
ans = max({ans,tot[m1], tot[m2]});
}
//if(!i) break;
}
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... |