#include<bits/stdc++.h>
using namespace std;
int n,k,k2,a[10001],c[1000001],s;
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
if(c[a[i]]!=1)
s++;
c[a[i]]=1;
}
k2=k;
for(int i=1;i<=k2;i++){
if(c[i]!=1)
k2++;
}
if(k>s)
cout<<"NO RESULT";
else
cout<<k2;
return 0;
}
为啥上面#4#9RE 但下面代码AC
#include<bits/stdc++.h>
using namespace std;
int n,k,a[10001],c[1000001],s;
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
if(c[a[i]]!=1)
s++;
c[a[i]]=1;
}
if (k>s){
cout<<"NO RESULT";
return 0;
}
for(int i=1;i<=k;i++){
if(c[i]!=1)
k++;
}
cout<<k;
return 0;
}
难道一定要提前判断可下面我又没对‘k’做处理