难道只有我用set嘛...23333
查看原帖
难道只有我用set嘛...23333
1321841
yihan168555楼主2024/3/24 18:55
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    set<int> s;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        s.insert(a[i]);
    }
    if(k > s.size()) {
        cout << "NO RESULT";
        return 0;
    }
    set<int>:: iterator it;
    it = s.begin();
    int t = 1;
    while(t < k) {
        it++;
        t++;
    }
    cout << *it;
    return 0;
}
2024/3/24 18:55
加载中...