社区讨论
60分求助
P1540[NOIP 2010 提高组] 机器翻译参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @lo8c0oae
- 此快照首次捕获于
- 2023/10/27 16:08 2 年前
- 此快照最后确认于
- 2023/10/27 16:08 2 年前
CPP
#include<bits/stdc++.h>
using namespace std;
/*inline long long read()
{
char c=getchar();
long long x=0,f=1;
while(c<'0'||c>'9'){
if(c=='-')
f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=x*10+c-'0';
c=getchar();
}
return x*f;
}
inline void write(long long x)
{
if(x<0){
putchar('-');
x=-x;
}
if(x>9)
write(x/10);
putchar(x%10+'0');
}*/
int dic[1005],frontt,endt;
int n,m,ans;
bool in(int x){
for(int i=frontt;i<=endt;i++){
if(dic[i]==x)return 1;
}
return 0;
}
int main()
{
scanf("%d%d",&m,&n);
frontt=0;
endt=0;
for(;n;n--){
int word;
scanf("%d",&word);
if(!in(word)&&endt<m){
dic[endt++]=word;
ans++;
}
else if(!in(word)&&endt>=m){
frontt++;
dic[endt++]=word;
ans++;
}
}
cout<<ans<<endl;
return 0;
}
回复
共 2 条回复,欢迎继续交流。
正在加载回复...