luogu 找第k小数

#include<bits/stdc++.h>
using namespace std;
const int N = 10000;
vector <int> v;
int n,k,icin;

int main(){
    ios::sync_with_stdio(false);
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>icin;
        v.push_back(icin);
    }
    vector<int>::iterator it_new_end;

    sort(v.begin(),v.end());
    it_new_end=unique(v.begin(),v.end());
    v.erase(it_new_end,v.end());
    //for(int i=0;i<v.size();i++) cout<<v[i]<<" ";
    int len=v.size();
    if(k>len) cout<<"NO RESULT"<<endl;
    else cout<<v[k-1]<<endl;
    return 0;
}

 

posted @ 2021-04-09 22:30  limited_Infinite  阅读(26)  评论(0编辑  收藏  举报
// //返回顶部 //返回顶部按钮