信息学奥赛一本通答案dj机器翻译1401

#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++基础的,关注我。

求点赞!

猜你喜欢

转载自blog.csdn.net/m0_73220913/article/details/129801854
今日推荐