webCode/Luogu/P1540/P1540.cpp

34 lines
622 B
C++
Raw Permalink Normal View History

2023-10-05 10:09:31 +00:00
#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;
}