1011
2
30%的数据 串的长度<20
程序:
var s:ansistring; i,j,min,max,p,l:longint; min1,max1:array[-1000001..1000001]of longint; begin fillchar(min1,sizeof(min1),127); min1[0]:=0; readln(s); min:=maxlongint; p:=0; max:=0; for i:=1 to length(s) do if s[i]='1' then begin inc(p); if p>max then max:=p; if p<min then min:=p; if i<min1[p] then min1[p]:=i; if i>max1[p] then max1[p]:=i; end else begin dec(p); if p>max then max:=p; if p<min then min:=p; if i<min1[p] then min1[p]:=i; if i>max1[p] then max1[p]:=i; end; for i:=min to max do if l<max1[i]-min1[i] then l:=max1[i]-min1[i]; write(l); end.