https://codeforces.com/contest/1138/problem/B
A
用vector压入容易出错
考虑 2 1 1
1 2 这几种情况 压入不能漏
ll a[maxn];
vector<int> v;
int main(){
cin>>n;
rep(i,1,n)
cin>>a[i];
cnt=1;
for(int i=2;i<=n;i++){
if(a[i-1]==a[i]){
cnt++;
if(i==n)
v.pb(cnt);
}
else{
v.pb(cnt);
cnt=1;
if(i==n)
v.pb(cnt);
}
}
for(auto k:v){
q++;
// cout<<k<<" ";
}
// cout<<endl;
// cout<<q<<endl;
int num=min(v[0],v[1]),ans=num;
for(int i=2;i<q;i++){
ans=max(ans,min(v[i-1],v[i]));
}
cout<<ans*2<<endl;
return 0;
}
ll n,m,T,ww[maxn],vis[maxn],ans;
ll a[maxn];
//376EF
vector<int> v;
int main(){
cin>>n;
rep(i,1,n)
cin>>a[i];
ll cnt=1,lastcnt=0;
rep(i,2,n+1){
if(a[i-1]==a[i]){
cnt++;
}
else{
if(lastcnt==0){
lastcnt=cnt;
cnt=1;
}
else
ans=max(ans,min(lastcnt,cnt));
}
}
cout<<2*ans<<endl;
return 0;
}