比赛 NOIP_1 评测结果 AAAWTTTTTT
题目名称 画展 最终得分 30
用户昵称 dingding 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-09-03 20:59:08
显示代码纯文本
program ap;
var
   ch:array[1..2000] of boolean;
   pic:array[1..1000000] of integer;
   n,m,a,b,min,mina,minb,i,j:longint;
   f:text;
   yon:boolean;
procedure check(a,b:longint);
var i,j:longint;
begin
    for i:=1 to m do
    ch[i]:=false;
    for i:=a to b do
    ch[pic[i]]:=true;
    yon:=false;
    for i:=1 to m do
    if ch[i]=false then begin yon:=true;exit; end;
end;
begin
   assign(f,'exhibit.in');
   reset(f);
   readln(f,n,m);
   for i:=1 to n do begin
   read(f,j); pic[i]:=j;
   end;
   close(f);
   min:=n; mina:=1;
   for i:=1 to n-m+1 do begin
   a:=i; b:=i+m-2; yon:=true;
   while (b<=n) and yon do begin
   check(a,b);
   if yon=false then
   if b+1-a<min then begin min:=b+1-a; mina:=a; minb:=b; end else
    if (b+1-a=min) and (mina>a) then begin mina:=a; minb:=b;  end;
   inc(b);
   end;
   end;
   assign(f,'exhibit.out');
   rewrite(f);
   writeln(f,mina,' ',minb);
   close(f);
end.