i,j,m,n,k,s,c:integer;a:array[1..1000]of integer;
man:boolean;b:array[1..1000]of integer;
begin
readln(m,n);
fillchar(b,sizeof(b),0);
for j:=1 to n do
read(a[j]);
s:=0;k:=0;
c:=0;i:=0;
while i<>n do
begin
inc(i);
if s=m then man:=true;
if (not man) and(b[a[i]]<>0) then
begin
inc(b[a[i]]);
inc(s);
end;
if (not man)and(b[a[i]]=0) then
begin
inc(b[a[i]]);
inc(c);
inc(s);
end;
if man and (b[a[i]]<>0) then
begin
inc(k);
dec(b[a[k]]);
inc(b[a[i]]);
end;
if man and (b[a[i]]=0) then
begin
inc(k);
inc(c);
dec(b[a[k]]);
inc(b[a[i]]);
end;
end;
writeln(c);
end.
这是我的
var n,m,s,x,i:longint;
a:array[0..1000] of longint;
b:array[0..1000] of boolean;
begin
readln(m,n);
fillchar(b,sizeof(b),#);
for i:=1 to n do
begin
read(x);
if b[x] then
begin
inc(s); a[s]:=x; b[x]:=false;
if s>m then b[a[s-m]]:=true;
end;
end;
writeln(s);
end.