30分求调awa
查看原帖
30分求调awa
1252442
lucy2012楼主2024/8/22 11:43
#include<bits/stdc++.h>
using namespace std;
queue<int> q;
int m,n,ans;
int main(){
    cin>>m>>n;
    for(int i=1;i<=n;i++){
    	int x,now=q.front(),tmp=0;
    	cin>>x;
    	if(now==x){
    		continue;
		}
		q.push(now);
    	q.pop();
    	while(q.front()!=now){
    		if(q.front()==x){
    			tmp=1;
    			break;
			}
			q.push(q.front());
    		q.pop();
		}
		if(tmp){
			continue;
		}
		ans++;
		if(q.size()==m){
			q.pop();
			q.push(x);
		}else{
			q.push(x);
		}
	}
	cout<<ans;
    return 0;
}
2024/8/22 11:43
加载中...