Files
python/TangDou/XiTi/1374.cpp

29 lines
555 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
int n, m, num = 0, ans = 0;
//利用数组桶排
bool path[1001] = {0};
queue<int> Q;
int main() {
cin >> m >> n;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
if (!path[x]) {
num++;
ans++;
Q.push(x);
path[x] = 1;
if (num > m) {
path[Q.front()] = 0;
Q.pop();
num--;
}
}
}
cout << ans << endl;
return 0;
}