比赛 NOIP_1 评测结果 AAAATTTTTT
题目名称 画展 最终得分 40
用户昵称 bly1991 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-10-12 11:41:18
显示代码纯文本
program bly(input,ouput);
var
  x:array[1..1000000] of longint;
  h:array[1..1000] of longint;
  i,j,k:longint;
  n,m,ans,a,b,min,num:longint;
  f1,f2:text;
begin
  assign(f1,'exhibit.in');
  reset(f1);
  readln(f1,n,m);
  for i:=1 to n do read(f1,x[i]);
  close(f1);

  min:=maxlongint;
  for i:=1 to n do begin
    for j:=i+1 to n do begin
      num:=j-i+1;
      for k:=i to j do inc(h[x[k]]);
      for k:=1 to m do if h[k]<>0 then inc(ans);
      if (ans=m)and(num<min) then begin min:=num; a:=i; b:=j; end;
      for k:=1 to m do h[k]:=0;
      ans:=0;
    end;
  end;
  assign(f2,'exhibit.out');
  rewrite(f2);
  writeln(f2,a,' ',b);
  close(f2);
end.