社区讨论
0分
P1540[NOIP 2010 提高组] 机器翻译参与者 2已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @miin3tip
- 此快照首次捕获于
- 2025/11/28 17:08 3 个月前
- 此快照最后确认于
- 2025/11/29 15:20 3 个月前
CPP
#include<bits/stdc++.h>
using namespace std;
int n,m;
int main() {
cin>>n>>m;
queue<int>q;
int op=0;
map<int,int>b;
for(int i=0;i<m;i++){
int u;
cin>>u;
if(b[i]==0){
op++;
q.push(u);
if(q.size()>=n){
b[q.front()]=0;
q.pop();
}
q.push(u);
b[u]=1;
}
}
cout<<op;
return 0;
}
回复
共 3 条回复,欢迎继续交流。
正在加载回复...