제출 #814610

#제출 시각아이디문제언어결과실행 시간메모리
814610Hanksburger서열 (APIO23_sequence)C++17
28 / 100
226 ms31728 KiB
#include "sequence.h" #include <bits/stdc++.h> using namespace std; int freq[2005][2005], freqsum[2005][2005]; int sequence(int n, vector<int> a) { for (int i=0; i<n; i++) freq[i][a[i]]++; for (int i=1; i<n; i++) for (int j=1; j<=n; j++) freq[i][j]+=freq[i-1][j]; for (int i=0; i<n; i++) for (int j=1; j<=n; j++) freqsum[i][j]=freqsum[i][j-1]+freq[i][j]; int ans=0; for (int i=0; i<n; i++) { for (int j=i; j<n; j++) { int l=1, r=n; while (l<r) { int mid=(l+r)/2; if (freqsum[j][mid]-(i==0?0:freqsum[i-1][mid])>=(j-i+2)/2) r=mid; else l=mid+1; } ans=max(ans, freq[j][l]-(i==0?0:freq[i-1][l])); l=1, r=n; while (l<r) { int mid=(l+r)/2; if (freqsum[j][mid]-(i==0?0:freqsum[i-1][mid])>=(j-i+3)/2) r=mid; else l=mid+1; } ans=max(ans, freq[j][l]-(i==0?0:freq[i-1][l])); } } 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...