记录编号 2561 评测结果 AAAAAAAAAA
题目名称 画展 最终得分 100
用户昵称 GravatarMayLava 是否通过 通过
代码语言 Pascal 运行时间 0.331 s
提交时间 2008-09-22 20:56:24 内存使用 7.74 MiB
显示代码纯文本
program MayLava;
var
 a,b:array[0..1000001]of longint;
 p,q,total,painter,n,m,min,x,y:longint;
procedure start;
 var
  i:longint;
  f:text;
 begin
  assign(f,'exhibit.in');
  reset(f);
  readln(f,n,m);
  for i:=1 to n do
   read(f,a[i]);
  close(f);
  p:=0;
  q:=0;
  total:=0;
  painter:=0;
  min:=maxint;
 end;
procedure main;
 var
  i,j:longint;
 begin
  while (p<n) or ((p=n) and (painter<m)) do begin
   if painter<m then begin
    inc(p);
    if b[a[p]]=0 then inc(painter);
    inc(b[a[p]]);
    inc(total);
    if painter=m then if total<min then begin min:=total; x:=q; y:=p; end;
   end;
   if (total>=m) and (painter=m) then begin
    inc(q);
    dec(b[a[q]]);
    if b[a[q]]=0 then begin
     if painter=m then
      if total<min then begin min:=total; x:=q; y:=p; end;
     dec(painter);
    end;
    dec(total);
   end;
  end;
 end;
procedure print;
 var
  f:text;
 begin
  assign(f,'exhibit.out');
  rewrite(f);
  if x=0 then inc(x);
  writeln(f,x,' ',y);
  close(f);
 end;
BEGIN
 start;
 main;
 print;
END.