Submission #982053

#TimeUsernameProblemLanguageResultExecution timeMemory
982053vjudge1Sequence (APIO23_sequence)C++17
28 / 100
2031 ms37584 KiB
#include "sequence.h" #include <bits/stdc++.h> #define rep(a,b,c) for(int a=b; a<c; a++) #define pb push_back using namespace std; int sequence(int N, vector<int> A) { int MAX=0, ans=0; rep(i,0,N) MAX=max(MAX,A[i]); MAX+=5; if(N*MAX>1e7) return 5; vector<vector<int>> cont(MAX), acum(MAX); rep(i,0,N){ acum[0].pb(0); cont[0].pb(0); } rep(k,1,MAX){ cont[k].pb(0); acum[k].pb(0); rep(i,1,N+1){ cont[k].pb(cont[k][i-1]+(A[i-1]==k)); acum[k].pb(cont[k][i]+acum[k-1][i]); } } rep(i,1,N+1){ rep(j,i,N+1){ rep(k,j-i,j-i+2){ int l=1, r=MAX, mid; while(l<=r){ mid=(l+r)>>1; if(acum[mid][j]-acum[mid][i-1]<(k/2+1)) l=mid+1; else r=mid-1; } ans=max(ans,cont[l][j]-cont[l][i-1]); } } } return ans; }
#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...