#include<bits/stdc++.h> using namespace std; const int maxn=500011; const int inf=1<<27; #define LL long long #define P pair<int,int> #define pb push_back #define cl(a,b) memset(a,b,sizeof(a)); int a[maxn]; int main(){ int n; while(~scanf("%d",&n)){ for(int i=0;i<n;i++){ scanf("%d",&a[i]); } int L=0,R=0; int ans=0; for(int i=1;i<n;i++){ while(a[R]!=a[R+1]&&R+1<n)R++; int l=L+1,r=R-1; int tmp=0; while(l<=r){ a[l]=a[L];a[r]=a[R]; l++;r--; tmp++; } L=R=i; ans=max(ans,tmp); } printf("%d\n",ans); for(int i=0;i<n;i++){ printf("%d%c",a[i],i==n-1?‘\n‘:‘ ‘); } } return 0; }
时间: 2024-11-03 21:58:43