OIerWu_829
2025-01-09 15:16:30
题目传送门
用
#include <iostream>
#include <queue>
using namespace std;
const int N = 1005;
bool vis[N];
queue<int> q;
int main()
{
int n, m;
cin >> n >> m;
int ans = 0;
for (int i = 1; i <= m; i++)
{
int x;
cin >> x;
if (!vis[x])
{
ans++;
q.push(x);
vis[x] = true;
}
if (q.size() > n)
{
vis[q.front()] = false;
q.pop();
}
}
cout << ans;
return 0;
}