You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
555 B

#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;
}