比赛 NOIP_1 评测结果 AAAAAAAAAA
题目名称 画展 最终得分 100
用户昵称 王瑞祥K 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-07-20 11:24:47
显示代码纯文本
program exhibit(input,output);
var
 pic:array[1..1000000]of longint;
 man:array[1..2000]of longint;
 maxh,maxf,maxn,h,f,n,picture,artist,i,n2:longint;
begin
 assign(input,'exhibit.in');assign(output,'exhibit.out');
 reset(input); rewrite(output);
 readln(picture,artist);
 maxn:=-1; h:=1;
 fillchar(man,sizeof(man),0);
 n2:=0;
 for i:=1 to picture do read(pic[i]);
 readln;
 for i:=1 to picture do begin
  if man[pic[i]]=0 then begin
   man[pic[i]]:=1; inc(n2);
   inc(n); f:=i;
  end
  else begin
   man[pic[i]]:=man[pic[i]]+1;
   inc(n); inc(f);
   if pic[h]=pic[i] then begin
    while man[pic[h]]>1 do begin
     man[pic[h]]:=man[pic[h]]-1;
     if man[pic[h]]=0 then n2:=n2-1;
     dec(n); inc(h);
    end;
   end;
  end;
  if n2=artist then begin
   if (n<maxn)or(maxn=-1) then begin
    maxn:=n; maxh:=h; maxf:=f;
   end;
  end;
 end;
 writeln(maxh,' ',maxf);
 close(input); close(output);
end.