You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
478 B
C++
22 lines
478 B
C++
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
int main()
|
|
{
|
|
freopen("1.txt", "r", stdin);
|
|
int n, k, x;
|
|
scanf("%d%d", &n, &k);
|
|
priority_queue<int> hp;
|
|
for (int i = 0; i < n; i++)
|
|
scanf("%d", &x), hp.push(x);
|
|
while (k--)
|
|
{
|
|
x = hp.top();
|
|
hp.pop();
|
|
hp.push(x >> 1);
|
|
}
|
|
long long ans = 0;
|
|
for (int i = 0; i < n; i++)
|
|
ans += hp.top(), hp.pop();
|
|
printf("%lld", ans);
|
|
return 0;
|
|
} |