Last active
September 15, 2019 15:01
-
-
Save hecomi/dd181ad6af2defcc4c116218a3f9860d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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