Submission #977946

#TimeUsernameProblemLanguageResultExecution timeMemory
977946NexusSequence (APIO23_sequence)C++17
7 / 100
130 ms31660 KiB
#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) { if(i && A[i]==A[i-1])++y; else x=max(x,y),y=1; v[A[i]].push_back(i); } x=max(x,y); for(ll i=1;i<=N;++i) { if(v[i].size()<2)continue; y=v[i][v[i].size()-1]-v[i][0]+1; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...