P1540 机器翻译 题目
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<ctime>
#include<queue>
#include<stack>
#define rg register
#define lst long long
#define N 1050
using namespace std;
int m,n,use,fir=1,need;
int fy[N];
bool b[N];
inline int read()
{
rg int s=0,m=1;rg char ch=getchar();
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')m=-1,ch=getchar();
while(ch>='0'&&ch<='9')s=(s<<3)+(s<<1)+ch-'0',ch=getchar();
return s*m;
}
int main()
{
m=read(),n=read();
for(rg int i=1;i<=n;++i)
{
rg int x=read();
if(!b[x])
{
if(use==m+fir-1)
{
b[fy[fir++]]=0;
}
need++;
fy[++use]=x;b[x]=1;
}
}
cout<<need<<endl;
return 0;
}