比赛 |
NOIP_1 |
评测结果 |
AAAAAAAAAA |
题目名称 |
画展 |
最终得分 |
100 |
用户昵称 |
francis |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-09-03 21:27:01 |
显示代码纯文本
program exhibit;
const
fin='exhibit.in';
fou='exhibit.out';
var
a:array[1..1000000]of longint;
b:array[1..2000]of longint;
total,k,all,p,q,min,n,m,i,j:longint;
f1,f2:text;
procedure init;
begin
assign(f1,fin); assign(f2,fou);
reset(f1); rewrite(f2);
read(f1,n,m);
for i:=1 to n do
read(f1,a[i]);
b[a[1]]:=1;
all:=1;
p:=1; q:=1;
i:=1; j:=1; min:=1000001; total:=1;
if all=m then begin write(f2,p,q); close(f1); close(f2); halt; end;
end;
begin
init;
for k:=2 to n do
begin
if b[a[k]]>0 then
begin
if a[k]=a[i] then
begin
inc(i); inc(j);
while b[a[i]]>1 do begin dec(b[a[i]]); inc(i); dec(total); end;
end
else begin inc(total); inc(b[a[k]]); j:=k; end;
end;
if b[a[k]]=0 then begin inc(all); inc(total); j:=k; b[a[k]]:=1; end;
if (all=m)and(total<min) then begin min:=total; p:=i; q:=j; end;
end;
write(f2,p,' ',q);
close(f1); close(f2);
end.