Files
lanqiao/15lanqiao/test7.cpp

28 lines
707 B
C++

// 爬山(不考虑hack数据)
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
// 贪心 + 堆维护最值, 时间复杂度 O(nlogn)
int main(){
priority_queue<int> pq; // 大根堆
int n, p ,q; cin >> n >> p >> q;
for(int i = 1; i <= n; i++){
int x; cin >> x;
pq.push(x);
}
while(p || q){
int cur = pq.top(); // 最大值
pq.pop();
if(p){ cur = sqrt(cur); p--; } // 优先消耗p(开根号)
else if(q) { cur = cur / 2; q--; }
pq.push(cur);
}
int s = 0; // 总的消耗
while(!pq.empty()) { s += pq.top(); pq.pop(); }
cout << s << endl;
return 0;
}
/* test samples -> 18
4 1 1
4 5 6 49
*/