mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
Upload via code
This commit is contained in:
34
FZOI/The kth great number(对顶堆).cpp
Normal file
34
FZOI/The kth great number(对顶堆).cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include <bits/stdc++.h>
|
||||
#define int long long
|
||||
using namespace std;
|
||||
|
||||
signed main()
|
||||
{
|
||||
int n, k;
|
||||
cin >> n >> k;
|
||||
|
||||
vector<int> nums;
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
char op;
|
||||
cin >> op;
|
||||
|
||||
if (op == 'I')
|
||||
{
|
||||
int num;
|
||||
cin >> num;
|
||||
nums.push_back(num);
|
||||
}
|
||||
else if (op == 'Q')
|
||||
{
|
||||
if (nums.size() >= k)
|
||||
{
|
||||
sort(nums.begin(), nums.end(), greater<int>());
|
||||
cout << nums[k - 1] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user