浴谷P1540 机器翻译
#include<bits/stdc++.h>
using namespace std;
int m;
int n;
queue<int> memory;
bool inQueue[100003];
int main()
{
scanf("%d %d",&m,&n);
int cnt=0;
for(int i=0;i<n;i++){
int x;
scanf("%d",&x);
if(!inQueue[x]){
cnt++;
memory.push(x);
inQueue[x]=true;
if(memory.size()>m){
inQueue[memory.front()]=false;
memory.pop();
}
}
}
cout<<cnt<<endl;
return 0;
}
来源:CSDN
作者:weixin_44026260
链接:https://blog.csdn.net/weixin_44026260/article/details/104309619