#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int N, K;
    std::cin >> N >> K;
    
    std::vector<int> nums(N);
    for(int i = 0; i < N; i++) {
        std::cin >> nums[i];
    }
    
    std::sort(nums.begin(), nums.end(), std::greater<int>());
    
    std::cout << nums[K-1] << std::endl;
    
    return 0;
}
C++ 算法题:求数组中第 K 大的数

原文地址: https://www.cveoy.top/t/topic/qo4p 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录