#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define endl "\n"
#define pb push_back
using namespace std;
using namespace __gnu_pbds;
template<typename T> using ordered_multiset=tree<pair<T, int>,null_type,less<pair<T, int>>,rb_tree_tag,tree_order_statistics_node_update>;
int sequence(int n, vector<int> v){
int u=0,d=0;
map<int,int> m;
for (int i=0; i<n; i++)
{ordered_multiset<int> os;
m.clear();
for (int j=1; j<=n-1; j++)
{int val=v[i+j-1];
m[val]++;
os.insert({val,d++});
int sz=os.size();
if (sz%2==1){int m1=os.find_by_order(sz/2)->first;u=max(u,m[m1]);}
else{int m1=os.find_by_order(sz/2-1)->first;int m2=os.find_by_order(sz/2)->first;u=max({u,m[m1],m[m2]});}
}
}
return u;
}
# | 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... |