34 lines
622 B
C++
34 lines
622 B
C++
#include <algorithm>
|
|
#include <iostream>
|
|
#include <queue>
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
int M,N;
|
|
int Ans=0;
|
|
queue<int> q;
|
|
|
|
int main(){
|
|
cin>>M>>N;
|
|
for (int i=1;i<=N; i++) {
|
|
int word;
|
|
cin>>word;
|
|
bool isIn = false;
|
|
auto nextq = q;
|
|
while (nextq.size()>0) {
|
|
if (nextq.front()==word) {
|
|
isIn=true;
|
|
break;
|
|
}
|
|
nextq.pop();
|
|
}
|
|
if (!isIn) {
|
|
Ans++;
|
|
q.push(word);
|
|
if (q.size()>M) {
|
|
q.pop();
|
|
}
|
|
}
|
|
}
|
|
cout<<Ans<<endl;
|
|
} |