Likecloud 2008-11-09 03:25:00
点我顶贴
收藏
删除
这是我的程序
program happy;
var
n,d,s,i,k,x,l:longint;
p:array[0..32767] of longint;
b:array[1..1000000] of longint;
begin
read(n,d);
s:=1; k:=0;
for i:=1 to n do
begin
read(b[i]);
if p[b[i]]=0 then inc(l);
inc(p[b[i]]);
if i+1>d+s then
begin
dec(p[b[s]]);
if p[b[s]]=0 then dec(l);
inc(s);
end;
while p[b[s]]>1 do
begin
dec(p[b[s]]);
inc(s);
end;
if (l>k) or (l=k) and (x+s>i+1) then begin k:=l; x:=i-s+1; end;
end;
writeln(k,’ ’,x);
end.