提交时间:2026-05-15 15:37:32

运行 ID: 88747

#include <iostream> #include <vector> #include <queue> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int k, n; cin >> k >> n; priority_queue<int, vector<int>, greater<int>> heap; // 小顶堆 for (int i = 0; i < n; ++i) { int x; cin >> x; if (heap.size() < k) { heap.push(x); } else if (x > heap.top()) { heap.pop(); heap.push(x); } } cout << heap.top() << endl; return 0; }