- C++
P353 【例61.1】 机器翻译
- @ 2026-5-5 14:35:51
#include<bits/stdc++.h> using namespace std; #define ll long long #define str string queue q; bool flag[1005]; int cnt; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int m,n; cin>>m>>n; for(int i=0;i<n;i++){ int x; cin>>x; if(!flag[x]){ if(q.size()>=m){ flag[q.front()]=0; q.pop(); } cnt++; flag[x]=1; q.push(x); } } cout<<cnt<<endl; return 0; } //3 7 //1 2 1 5 4 4 1
0 条评论
目前还没有评论...