比赛 NOIP_1 评测结果 AAAAAAAAAT
题目名称 画展 最终得分 90
用户昵称 打不死的羊 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-07-20 09:40:05
显示代码纯文本
program exhibit;
type
fxz1=array[1..1000000] of integer;
fxz2=array[1..2000] of longint;
var
f1,f2:text;
w,t,a,b,m,n,i:longint;
flag:boolean;
pic:fxz1;
num:fxz2;

  procedure jin;
  begin inc(w);
        inc(num[pic[w]]);
  end;
  procedure suo;
  begin dec(num[pic[t]]);
        inc(t);
  end;
  procedure pan(var flag:boolean);
  var
  i:longint;
  begin flag:=true;
        for i:=1 to m do
        if num[i]=0 then
        begin flag:=false;break;end;
  end;
begin
assign(f1,'exhibit.in');
assign(f2,'exhibit.out');
reset(f1);rewrite(f2);
readln(f1,n,m);
for i:=1 to n do read(f1,pic[i]);
t:=1;w:=0;a:=0;b:=n;
repeat flag:=false;
       while flag=false do
       begin jin;pan(flag);end;
       if w-t<b-a then begin a:=t;b:=w;end;
       while flag do
       begin suo;pan(flag);end;
       dec(t);inc(num[pic[t]]);
       if w-t<b-a then begin a:=t;b:=w;end;
until  (a-b=m-1)or(w=n);
writeln(f2,a,' ',b);
close(f1);close(f2);
end.