首页 > 其他分享 >【NOIP2010】【Luogu1540】机器翻译

【NOIP2010】【Luogu1540】机器翻译

时间:2023-02-08 11:36:40浏览次数:45  
标签:cout NOIP2010 int Luogu1540 机器翻译 pop ans include

problem

solution

codes

//STL大法好
#include<iostream>
#include<set>
#include<queue>
using namespace std;
queue<int>q;
set<int>s;
int main(){
    int m, n, ans = 0;
    cin>>m>>n;
    for(int i = 1; i <= n; i++){
        int x;  cin>>x;
        if(s.count(x))continue;
        else{
            ans++;
            q.push(x); s.insert(x);
            if(q.size()> m){
                s.erase(q.front()); 
                q.pop(); 
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}

标签:cout,NOIP2010,int,Luogu1540,机器翻译,pop,ans,include
From: https://blog.51cto.com/gwj1314/6043786

相关文章