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>
#define ll long long
#define mid (r+l)/2
using namespace std;
const ll N=5e5+9,M=2e18+9,mod=1e9+7;
ll n,x,y,z;
vector<ll>v[N];
int sequence(int N, vector<int> A) {
x=1;
for(ll i=0;i<N;++i)
v[A[i]].push_back(i);
for(ll i=1;i<=N;++i)
{
if(v[i].size()<2)continue;
y=v[i][v[i].size()-1]-v[i][0];
z=y-v[i].size();
if(z<=N/2)x=max(x,(ll)v[i].size());
}
return x;
}
/*
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;
vector<int>g(n);
for(auto &i:g)cin>>i;
cout<<sequence(n,g);
}
*/
# | 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... |