xmjxxx @ 2023-03-15 00:39:08
#include<bits/stdc++.h>
using namespace std;
int record[100000000];
int max_num(int a,int b){
if(a<b)
return b;
else
return a;
}
int main(){
int n,k;
cin>>n>>k;
int maxnum;
for(int i=1;i<=n;i++){
int l;
cin>>l;
record[l]=1;
maxnum=max_num(maxnum,l);
}
int ans=0;
for(int i=1;i<=maxnum;i++){
ans+=record[i];
if(ans==k){
cout<<i;
break;
}
}
return 0;
}
by xmjxxx @ 2023-03-15 00:47:35
对了ans=-1不是0,写错啦