第十五届蓝桥杯:爬山
考察范围:贪心+优先级队列
#include <iostream>
#include <queue>
#include <cmath>
using namespace std;
priority_queue <int> heap;
int n,p,q;
int tmp;
int main()
{
cin >> n >> p >> q;
while(n--)
{
cin >> tmp;
heap.push(tmp);
}
while(p--)
{
int t = heap.top();
heap.pop();
heap.push(sqrt(t));
}
while(q--)
{
int t2 = heap.top();
heap.pop();
heap.push(t2/2);
}
int sum = 0;
while(heap.size() != 0)
{
int t3 = heap.top();
sum+=t3;
heap.pop();
}
cout << sum << endl;
return 0;
}