60分求助
查看原帖
60分求助
946328
HZA_qwq楼主2024/8/20 10:40
#include <bits/stdc++.h>
using namespace std;
int n,m,ans;
queue<int> q;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>m>>n;
    for(int i=1;i<=n;i++){
    	int op,f=0;
    	cin>>op;
    	for(int j=0;j<m;j++){
    		int x=q.front();
			q.pop();
			q.push(x);
			if(x==op){
				f=1;
			}
		}
		if(!f){
			ans++;
			if(q.size()==m){
				q.pop();
				q.push(op);
			}else{
				q.push(op);
			}
		}
	}
	cout<<ans;
    return 0;
}
2024/8/20 10:40
加载中...