求助!
查看原帖
求助!
951510
Atimmy楼主2024/3/23 16:43
#include <bits/stdc++.h>
using namespace std;
int m,ci,sm,h,t;
int p[1009];
int main()
{
	cin>>m>>ci;
	for(int i=0;i<ci;i++)
	{
		int x;
		cin>>x;
		bool oo=0;
		for(int j=h;j<t;j++)
		{
			if(p[j]==x)
			{
				oo=1;
				break;
			}
		}
		if(oo)
		{
			sm++;
			if(t-h==m)
			{
				h++;
			}
			p[t]=x;t++;
		}
	}
	cout<<sm;
	return 0;
}
2024/3/23 16:43
加载中...