蒟蒻60分求助
查看原帖
蒟蒻60分求助
604622
achjuncool楼主2022/6/21 19:04

代码如下qwq:

#include <iostream>
#include <queue>
using namespace std;
int ans, m, n, t;
bool searched[1005];
queue<int> a;
int main(){
	cin >> m >> n;
	for(int i = 1; i <= n; i++){
		cin >> t;
		if(!searched[t]){
			ans++;
			a.push(t);
			searched[t] = true;
		}
		if(a.size() >= m){
			searched[a.front()] = false;
			a.pop();
		}
	}
	cout << ans << endl;
	return 0;
}
2022/6/21 19:04
加载中...