제출 #982043

#제출 시각아이디문제언어결과실행 시간메모리
982043vjudge1서열 (APIO23_sequence)C++17
0 / 100
95 ms71760 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; int cont[MAX][N+1]{}, acum[MAX][N+1]{}; rep(k,1,MAX){ rep(i,1,N+1){ cont[k][i]=cont[k][i-1]+(A[i-1]==k); acum[k][i]=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=N, 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...