Skip to content

Instantly share code, notes, and snippets.

@hecomi
Last active September 15, 2019 15:01
Show Gist options
  • Save hecomi/dd181ad6af2defcc4c116218a3f9860d to your computer and use it in GitHub Desktop.
Save hecomi/dd181ad6af2defcc4c116218a3f9860d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <queue>
using namespace std;
int main()
{
int N, M;
cin >> N >> M;
priority_queue<int> products;
for (int i = 0; i < N; ++i)
{
int price;
cin >> price;
products.push(price);
}
for (int i = 0; i < M; ++i)
{
int price = products.top();
products.pop();
price /= 2;
products.push(price);
}
long total = 0;
while (!products.empty())
{
total += products.top();
products.pop();
}
cout << total << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment