| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 88747 | sh25_zhangyj | 求第k大数 | C++ | 解答错误 | 0 MS | 268 KB | 565 | 2026-05-15 15:37:32 |
#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; }