比赛 |
20120711 |
评测结果 |
AAAAAAAWAWWA |
题目名称 |
平衡奶牛 |
最终得分 |
75 |
用户昵称 |
czp |
运行时间 |
0.647 s |
代码语言 |
Pascal |
内存使用 |
11.99 MiB |
提交时间 |
2012-07-11 11:42:50 |
显示代码纯文本
var
sum:array[0..30,0..100000] of longint;
p:array[1..33] of longint;
i,j,m,n,l,v,ml,k,limit,ct:longint;
bbbb:boolean;
begin
assign(input,'balline.in');reset(input);
assign(output,'balline.out');rewrite(output);
readln(n,k);
p[1]:=1;
randomize;
for i:=2 to k do p[i]:=p[i-1]*2;
for i:=1 to n do
begin
readln(m);
for j:=1 to k do
begin
sum[j,i]:=sum[j,i-1];
if m and p[j]=p[j] then inc(sum[j,i]);
end;
end;
if n<=3000 then begin
for i:=1 to n do
begin
for j:=1 to n-i+1 do
begin
v:=sum[1,j+i-1]-sum[1,j-1];
bbbb:=true;
for l:=2 to k do
if sum[l,j+i-1]-sum[l,j-1]<>v then
begin bbbb:=false;break; end;
if bbbb then begin
if i>ml then ml:=i;
end;
end;
end;
writeln(ml);
end else begin
ct:=0;
repeat
inc(ct);
i:=random(n-ml)+1;
j:=random(n-i+1)+1;
v:=sum[1,j+i-1]-sum[1,j-1];
bbbb:=true;
for l:=2 to k do
if sum[l,j+i-1]-sum[l,j-1]<>v then
begin bbbb:=false;break; end;
if bbbb then if i>ml then ml:=i;
until ct>1000000;
writeln(ml);
end;
close(input);close(output);
end.