| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1333859 | hmms127 | Sequence (APIO23_sequence) | C++20 | 0 ms | 0 KiB |
#include "sequence.h"
#include <vector>
#include "bits/stdc++.h"
using namespace std;
int sequence(int n, vector<int> a) {
int ans=0;
for (int l=0;l<n;l++) {
vector<int>v;vector<int>frq(n+1,0);
for (int r=l;r<n;r++) {
v.pb(a[r]);
frq[a[r]]++;
sort(v.begin(),v.end());
if ((r-l+1)%2) {
ans=max(ans,frq[v[(int)(v.size()/2)]]);
}
else ans=max({ans,frq[v[(int)(v.size()/2)]],frq[v[(int)(v.size()/2)-1]]});
}
}
return ans;
}
