扫一遍,遇到相同的颜色就重新记录,否则cnt++
#include<bits/stdc++.h>
using namespace std;
#define maxn 100000
#define read(x) scanf("%d",&x)
int n,k;
int main() {
read(n),read(k);
int s=0,y=0,cnt=0;
for(int i=1;i<=n;i++) {
int x;
read(x);
if(x==y) {
cnt=1;
} else cnt++;
s=max(s,cnt);
y=x;
}
printf("%d",s);
return 0;
}