求大佬。
#include<bits/stdc++.h>
using namespace std;
int n,m,x,sum;
struct node{
int data;
node *next;
};
node *head,*p,*r;
int main()
{
cin>>m>>n;
head=new node;
r=head;p=head->next;
for(int i=1;i<=n;i++){
p=new node;
p->data=-1;
p->next=NULL;
r->next=p;
r=p;
}
for(int i=1;i<=n;i++){
cin>>x;
p=head->next;
int l=0,r=0;
for(int j=1;j<=m;j++){
if(p->data!=-1) l++;
if(p->data==x) r=1;
p=p->next;
}
if(r!=1){
if(l==m){
p=head->next;
p->data=x;
}
else{
p=head->next;
while(p->data!=-1) p=p->next;
p->data=x;
}
sum++;
}
}
cout<<sum<<endl;
return 0;
}