提交时间:2026-04-10 15:30:32
运行 ID: 87048
#include <iostream> #include <queue> #include <vector> using namespace std; int main() { int M, N; cin >> M >> N; queue<int> mem; vector<bool> exist(1001, false); int ans = 0; for (int i = 0; i < N; i++) { int word; cin >> word; if (exist[word]) { continue; } ans++; if (mem.size() == M) { int old = mem.front(); mem.pop(); exist[old] = false; } mem.push(word); exist[word] = true; } cout << ans << endl; return 0; }