除2!

import java.util.*;

public class Main{

public static void main(String[] args){

Scanner in = new Scanner(System.in);

int n = in.nextInt(), k = in.nextInt();

PriorityQueue<Integer> heap = new PriorityQueue<>(

(a, b) -> {return b - a;});

long sum = 0, x;

for(int i = 0; i < n; i++){

x = in.nextLong();

sum += x;

if(x % 2 == 0){

heap.add((int)x);

}

}

while(!heap.isEmpty() && k-- != 0){

long t = heap.poll() / 2;

sum -= t;

if(t % 2 == 0){

heap.add((int)t);

}

}

System.out.println(sum);

}

}

全部评论

相关推荐

你背过凌晨4点的八股文么:简历挂了的话会是流程终止,像我一样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务