#include<iostream>
#include<queue>
using namespace std;
int m,n;
int word,cnt=0;
bool vis[1005]={0};
int main()
{
queue <int> mem;
cin>>m>>n;
for(int i=1;i<=n;i++)
{
cin>>word;
if(!vis[word])
{
cnt++;
if(mem.size()>=m)
{
vis[mem.front()]=false;
mem.pop();
}
mem.push(word);
vis[word]=true;
}
}
cout<<cnt;
return 0;
}
想要其他题目答案,黑客小程序,或c++基础的,关注我。
求点赞!