比赛 |
NOIP_1 |
评测结果 |
AAAAAAAAAA |
题目名称 |
画展 |
最终得分 |
100 |
用户昵称 |
辨机ZN |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-07-20 10:10:53 |
显示代码纯文本
program ex(f1,f2);
type
zn=array [1..2000] of longint;
ka=array [1..1000000] of integer;
var
a:ka; f1,f2:text; i,j,k,m,n,p,l:longint;
ans,tot,left,right,ll,rr,eginer:longint;
c:zn; flag:boolean;
begin
assign(f1,'exhibit.in'); reset(f1);
assign(f2,'exhibit.out'); rewrite(f2);
readln(f1,n,m);
for i:=1 to m do c[i]:=0;
for i:=1 to n do read(f1,a[i]);
flag:=true;
left:=1;
right:=1;
ans:=n;
tot:=1;
c[a[1]]:=1;
while right<n do
begin
if tot=m then
begin
if right-left+1<ans then
begin
ll:=left;
rr:=right;
ans:=right-left+1;
end;
dec(c[a[left]]);
inc(left);
if c[a[left-1]]=0 then dec(tot);
end
else
begin
inc(right);
if c[a[right]]=0 then inc(tot);
inc(c[a[right]]);
end;
end;
if (left=1)and(right=n) then writeln(f2,left,' ',right)
else writeln(f2,ll,' ',rr);
close(f1);
close(f2);
end.