You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
351 B
C++

#include <cstdio>
int que[1001],head,tail,m,n,cnt;
bool mem[1001];
int main()
{
scanf("%d%d",&m,&n);
for(int i=0,x; i<n; i++)
{
scanf("%d",&x);
if(mem[x]) continue;
if(tail-head==m) mem[que[head++]]=false;
mem[que[tail++]=x]=true;
cnt++;
}
printf("%d",cnt);
return 0;
}