O(m)因为数据很水,所以全部放入数组中不需要删除。var a,b:array[0..1500] of longint; i,j,ans,n,m,x,y:longint; t:boolean;begin readln(n,m); for i:=1 to m do read(a[i]); x:=1; for i:=1 to m do begin t:=true; for j:=x to y do if b[j]=a[i] then begin t:=false;break;end; if not t then continue; inc(ans); inc(y); b[y]:=a[i]; if ans>n then inc(x); end; writeln(ans);end.