60分求助
查看原帖
60分求助
560545
A_HissingCreeper楼主2022/8/10 12:28
#include<bits/stdc++.h>
using namespace std;
/*inline long long read()
{
	char c=getchar();
	long long x=0,f=1;
	while(c<'0'||c>'9'){
		if(c=='-')
		    f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
inline void write(long long x)
{
	if(x<0){
		putchar('-');
		x=-x;
	}
	if(x>9)
	    write(x/10);
	putchar(x%10+'0');
}*/

int dic[1005],frontt,endt;
int n,m,ans;

bool in(int x){
	for(int i=frontt;i<=endt;i++){
		if(dic[i]==x)return 1;
	}
	return 0;
}

int main()
{
	scanf("%d%d",&m,&n);
	frontt=0;
	endt=0;
	for(;n;n--){
		int word;
		scanf("%d",&word);
		if(!in(word)&&endt<m){
			dic[endt++]=word;
			ans++;
		}
		else if(!in(word)&&endt>=m){
			frontt++;
			dic[endt++]=word;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}
2022/8/10 12:28
加载中...