1401

#include<iostream>
#include<set>
using namespace std;
int main(){
	int m,n,x=0,c[1000],p=-1;
	set<int> a;
	cin>>m>>n;
	int b;
	set<int>::iterator i;
	for(int i=0;i<n;i++){
		cin>>b;
		if(a.find(b)==a.end()){
			x++;
			a.insert(b);
			if(a.size()<=m){
				p++;
				p=p%m;
				c[p]=b;
			}else{
				p++;
				p=p%m;
				a.erase(c[p]);
				c[p]=b;
			}
		}
	}
	cout<<x<<endl;
	return 0;
}

  

posted @ 2024-01-29 11:16  陈若麟  阅读(18)  评论(0编辑  收藏  举报