Problem:


Score : 400 points

Problem Statement

Takahashi is going to buy N items one by one.

The price of the i-th item he buys is A_i yen (the currency of Japan).

He has M discount tickets, and he can use any number of them when buying an item.

If Y tickets are used when buying an item priced X yen, he can get the item for \frac{X}{2^Y} (rounded down to the nearest integer) yen.

What is the minimum amount of money required to buy all the items?

Constraints

All values in input are integers.

1 \leq N, M \leq 10^5

1 \leq A_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N M
A_1 A_2 ... A_N

Output

Print the minimum amount of money required to buy all the items.

Sample Input 1

3 3
2 13 8

Sample Output 1

9

We can buy all the items for 9 yen, as follows:

Buy the 1-st item for 2 yen without tickets.

Buy the 2-nd item for 3 yen with 2 tickets.

Buy the 3-rd item for 4 yen with 1 ticket.

Sample Input 2

4 4
1 9 3 5

Sample Output 2

6

Sample Input 3

1 100000
1000000000

Sample Output 3

0

We can buy the item priced 1000000000 yen for 0 yen with 100000 tickets.

Sample Input 4

10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 4

9500000000



Sample input:
3 3
2 13 8


Sample output:
9

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
for i in range(M):
  tmp=A.pop(0)
  tmp=tmp//2
  index=bl(A,tmp)
  A.insert(index-1,tmp)
print(sum(A))

Submission status: Wrong Answer

Solution code:
n,m=list(map(int, input().split()))
a=list(map(int, input().split()))
a.sort()
for i in range(m):
	a[-1]=a[-1]/2
	a.sort()
print(int(sum(a)))

Submission status: Wrong Answer

Solution code:
# input
n, m = map(int, input().split())
la = sorted(list(map(int, input().split())), reverse=True)

while m > 0:

    for i in range(n):
        if i == n-1:
            la[i] = la[i] // 2
            break
        elif i < n-1:
            if la[i] > la[i+1]:
                la[i] = la[i] // 2
                break

    # print(la)
    m -= 1

print(sum(la))

Submission status: Wrong Answer

Solution code:
class heap:
    def __init__(self,order="asc"):
        self._heap = []
        self.order=order
    def get_head(self):
        return self._heap[0] if self.order == "asc" else -self._heap[0]
    def get_heap(self):
        return self._heap if self.order == "asc" else list(map(lambda x:-x,self._heap))
    def enqueue(self,items):
        if type(items) != list:
            items = [items]
        # 降順ソートの場合は正負反転
        if self.order!="asc":
            items = list(map(lambda x:-x,items))
        for item in items:
            self._heap.append(item)
            self_idx = len(self._heap)-1
            parent_idx = self_idx//2
            while self_idx > 0:
                if self._heap[self_idx] <= self._heap[parent_idx]:
                    self._heap[self_idx], self._heap[parent_idx] = self._heap[parent_idx], self._heap[self_idx]
                    self_idx = parent_idx
                    parent_idx = self_idx//2
                else:
                    break
    def dequeue(self):
        head = self._heap[0]
        self._heap[0] = self._heap[-1]
        self._heap.pop(-1)
        self_idx = 0
        child_idx = [1,2]
        while True:
            # 子供が存在しなかったらbreak
            if child_idx[0] > len(self._heap)-1:
                break
            # 左の子供しか存在しない場合
            elif child_idx[0] == len(self._heap)-1:
                # 左の子供のほうが大きい場合
                if self._heap[self_idx] < self._heap[child_idx[0]]:
                    break
                else:
                    self._heap[self_idx],self._heap[child_idx[0]] = self._heap[child_idx[0]],self._heap[self_idx]
                    self_idx = (self_idx*2)+1
                    child_idx = [self_idx*2+1,self_idx*2+2]
            # 両方の子供が存在する場合
            else:
                # 子供のほうが大きい場合
                if self._heap[self_idx] < min([self._heap[child_idx[0]],self._heap[child_idx[1]]]):
                    break
                # 子供のほうが小さい場合
                else:
                    # 左の子供のほうが小さい場合は左の子供と親の値を交換
                    if self._heap[child_idx[0]] <= self._heap[child_idx[1]]:
                        self._heap[self_idx],self._heap[child_idx[0]] = self._heap[child_idx[0]],self._heap[self_idx]
                        self_idx = (self_idx*2)+1
                        child_idx = [self_idx*2+1,self_idx*2+2]
                    # 右の子供のほうが小さい場合は右の子供と親の値を交換
                    else:
                        self._heap[self_idx],self._heap[child_idx[1]] = self._heap[child_idx[1]],self._heap[self_idx]
                        self_idx = (self_idx*2)+2
                        child_idx = [self_idx*2+1,self_idx*2+2]
        return head
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
heap = heap(order="desc")
heap.enqueue(A)
for m in range(M):
    tmp = -heap.dequeue()
    tmp = tmp//2
    heap.enqueue(tmp)
print(sum(heap.get_heap()))

Submission status: Wrong Answer

Solution code:
N, M = input().split(" ")
N = int(N)
M = int(M)
num_list = list(map(int, input().split(" ")))
for i in range(M):
    num_list[len(num_list)-1] //= 2
    num_list.sort()
print(sum(num_list))

Submission status: Wrong Answer

Solution code:
import bisect

n, m = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort(reverse = True)

for i in range(m):
  a = aaa.pop(0)
  a = a // 2
  insert_index = bisect.bisect_left(aaa, a)
  aaa.insert(insert_index, a)
  
print(aaa)
print(sum(aaa))

Submission status: Wrong Answer

Solution code:
class heap:
    def __init__(self,order="asc"):
        self._heap = []
        self.order=order
    def get_head(self):
        return self._heap[0] if self.order == "asc" else -self._heap[0]
    def get_heap(self):
        return self._heap if self.order == "asc" else list(map(lambda x:-x,self._heap))
    def enqueue(self,items):
        if type(items) != list:
            items = [items]
        # 降順ソートの場合は正負反転
        if self.order!="asc":
            items = list(map(lambda x:-x,items))
        for item in items:
            self._heap.append(item)
            self_idx = len(self._heap)-1
            parent_idx = self_idx//2
            while self_idx > 0:
                if self._heap[self_idx] <= self._heap[parent_idx]:
                    self._heap[self_idx], self._heap[parent_idx] = self._heap[parent_idx], self._heap[self_idx]
                    self_idx = parent_idx
                    parent_idx = self_idx//2
                else:
                    break
    def dequeue(self):
        head = self._heap[0]
        self._heap[0] = self._heap[-1]
        self._heap.pop(-1)
        self_idx = 0
        child_idx = [1,2]
        while True:
            # 子供が存在しなかったらbreak
            if child_idx[0] > len(self._heap)-1:
                break
            # 左の子供しか存在しない場合
            elif child_idx[0] == len(self._heap)-1:
                # 左の子供のほうが大きい場合
                if self._heap[self_idx] < self._heap[child_idx[0]]:
                    break
                else:
                    self._heap[self_idx],self._heap[child_idx[0]] = self._heap[child_idx[0]],self._heap[self_idx]
                    self_idx = (self_idx*2)+1
                    child_idx = [self_idx*2+1,self_idx*2+2]
            # 両方の子供が存在する場合
            else:
                # 子供のほうが大きい場合
                if self._heap[self_idx] < min([self._heap[child_idx[0]],self._heap[child_idx[1]]]):
                    break
                # 子供のほうが小さい場合
                else:
                    # 左の子供のほうが小さい場合は左の子供と親の値を交換
                    if self._heap[child_idx[0]] <= self._heap[child_idx[1]]:
                        self._heap[self_idx],self._heap[child_idx[0]] = self._heap[child_idx[0]],self._heap[self_idx]
                        self_idx = (self_idx*2)+1
                        child_idx = [self_idx*2+1,self_idx*2+2]
                    # 右の子供のほうが小さい場合は右の子供と親の値を交換
                    else:
                        self._heap[self_idx],self._heap[child_idx[1]] = self._heap[child_idx[1]],self._heap[self_idx]
                        self_idx = (self_idx*2)+2
                        child_idx = [self_idx*2+1,self_idx*2+2]
        return head
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
heap = heap(order="desc")
heap.enqueue(A)
for m in range(M):
    tmp = -heap.dequeue()
    tmp = tmp//2
    heap.enqueue(tmp)
sum(heap.get_heap())

Submission status: Wrong Answer

Solution code:
import bisect

n, m = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort(reverse = True)

for i in range(m):
  a = aaa.pop(0)
  a = a // 2
  insert_index = bisect.bisect_right(aaa, a)
  aaa.insert(insert_index, a)
  
print(sum(aaa))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
A=[int(i) for i in input().split()]

A.sort()
A.reverse()
#print(A)
if n==1:
    ans=A[0]//(2**m)
    print(ans)
else:
    A.append(0)
    big=A[0]
    stc=0
    now=0
    while m>0:
        A[now]=A[now]//2
        m-=1
        big=A[0]
        for i in range(n-1):
            if A[i+1]>=big and m>0:
                A[i+1]=A[i+1]//2
                m-=1
            else:
                A.sort()
                A.reverse()
                break
        print(A)
    else:
        print(sum(A))

Submission status: Wrong Answer

Solution code:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush,heapreplace
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()
a = [-i for i in a]

for i in range(m):
    tmp = heappop(a)
    heappush(a,tmp//2)
print(-sum(a))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
use = 0
for i in range(N):
    X = max(A)
    Y = A.index(max(A))
    if use == M:
        break
    else:
        for j in range(M):
            if use == M:
                break
            if A[Y]!= max(A):
                break
            else:
                A[Y] = A[Y]//2
                use += 1
for i in range(N):
    ans += A[i]
print(ans)

Submission status: Wrong Answer

Solution code:

N, M=map(int,input().split())

Tmp = []
Tmp = input().rstrip().split(' ')

P = [ 0 for i in range(N)]

for i in range(N):
  P[i] = int(Tmp[i])

P.sort(reverse=True)
for i in range(N):
  P[0] /= 2
  P.sort(reverse=True)

Ans = 0
for i in range(N):
  Ans += P[i] // 1

print('%d' %(Ans))

Submission status: Wrong Answer

Solution code:
import numpy as np
if __name__ == "__main__":
  n, m = list(map(int, input().split())) 
  A = list(map(int, input().split()))
  A = np.array(A)

  for i in range(n):
    a = np.argmax(A)
    A[a] = A[a] // 2

  print(np.sum(A))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())

A = list(map(int, input().split()))

C = [0] * M
if N == 1:
    for i in range(M):
        A[0] = A[0] // 2
    print(A[0])
    exit(0)

while(M > 0):
    A.sort(reverse=True)
    for i in range(N - 1):
        if M <= 0:
            break
        if A[i] >= A[i+1]:
            A[i] = A[i] // 2
            M -= 1
print(sum(A))

Submission status: Wrong Answer

Solution code:
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    sort_A = sorted(A[:M], reverse=True)


    tmp = 0
    num = len(sort_A)
    for _ in range(M):
        sort_A[tmp] = sort_A[tmp] // 2
        if num != 1 and sort_A[tmp] < sort_A[tmp+1]:
            sort_A.sort(reverse=True)

    print(sum(sort_A) + sum(A[M:]))

main()

Submission status: Wrong Answer

Solution code:
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N, M = MAP()
    A = sorted(LIST(), reverse=True)
    sumv = sum(A)
    B = []
    x = 0
    for mm in range(M):
        if N > mm and A[mm] > x:
            B += [A[mm]]
        maxv = max(B)
        B.remove(maxv)
        x = maxv // 2
        B += [x]
        sumv -= (maxv - maxv // 2)
    print(max(sumv, 0))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

N, M = [int(x) for x in input().split()]
A_list = [int(x) for x in input().split()]

A_list.sort()
while M > 0:
    A_list[-1] = math.floor(A_list[-1] / 2)
    M -= 1

print(sum(A_list))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
data=input().rstrip().split(" ")
data[0]=int(data[0])
data[1]=int(data[1])
yen=input().rstrip().split(" ")
for i in range(data[0]):
    yen[i]=int(yen[i])
    
for i in range(data[1]):
    if data[0] >2:
        if(yen[0] < yen[1]):
            yen=sorted(yen,reverse=True)
    yen[0]=int(yen[0]/2)

ans=0
for i in range(data[0]):
    ans= ans + yen[i]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
d = {}

def solve(N, M, A, cur, remain):
  if cur == N:
    return 0
  else:
    if not (cur, remain) in d:
      a = A[cur]
      tmp = 10**10
      for i in range(remain+1):
        if a // (2**i) < 0:
          break
        tmp = min(tmp, solve(N, M, A, cur+1, remain-i)+a//(2**i))
      d[(cur, remain)] = tmp
    return d[(cur, remain)]
n, m = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, m, a, 0, m))

Submission status: Wrong Answer

Solution code:
import bisect
#from collections import deque

N, M = map(int, input().split())
A = list(map(int, input().split()))
#A = deque(sorted(A, reverse=True))
A.sort(reverse=True)

for i in range(M):
    a = A.pop(0)
    a /= 2
    index = bisect.bisect_left(A, a)
    A.insert(index-1, a)

ans = 0
for a in A:
    ans += a//1
print(int(ans))

Submission status: Wrong Answer

Solution code:
import math

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

for i in range(M):
    A[-1] /= 2
    A = sorted(A)

for j in range(N):
    A[j] = math.ceil(A[j])

print(sum(A))

Submission status: Wrong Answer

Solution code:
import heapq

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
h = []
for i in A:
    heapq.heappush(h, -i)

if len(A) == 1:
    print(A[0] // 2 ** M)
    exit()

used_discount_num = 0
for i in range(N):
    ma = -heapq.heappop(h)
    next_ma = -heapq.heappop(h)
    for j in range(used_discount_num, M):
        ma //= 2
        used_discount_num += 1
        if next_ma > ma:
            heapq.heappush(h, -ma)
            heapq.heappush(h, -next_ma)
            break
    if next_ma <= ma:
        heapq.heappush(h, -ma)
        heapq.heappush(h, -next_ma)
        break

print(-sum(h))

Submission status: Wrong Answer

Solution code:
import bisect

n, m = map(int, input().split())
aaa = list(map(int, input().split()))
aaa.sort()

for i in range(m):
  a = aaa.pop(-1)
  a = a // 2
  insert_index = bisect.bisect_left(aaa, a)
  aaa.insert(insert_index, a)
  
print(aaa)
print(sum(aaa))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	N,M = inputMap()
	A = inputList()

	A.sort()
	A = A[::-1]

	ans = 0
	for i,val in enumerate(A):
		#print(M)
		if M > 0:
			if i >= len(A)-1:
				ans += (val // (2**M))

			else:
				aa = 1
				for j in range(1,M+1):
					tmp = (val // 2**j)
					if tmp < (A[i+1] // 2):
						aa = j
						break

				M -= aa
				#print(aa)
				ans += (val // (2**aa))
		else:
			ans += val

	print(ans)


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import sys
import math
from heapq import heappush, heappop, heapify

N,M=map(int, raw_input().split())
A=map(int, sys.stdin.readline().split())
A=map(lambda a: a*-1, A)
heapify(A)

for _ in range(M):
	a=heappop(A)
	a=math.ceil(float(a)/2)
	heappush(A,a)

print sum(A)*-1

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=sorted(map(float,input().split()))

def searchmax(*a):
    m=a[0]
    p=0
    for i in range(n):
        if m<a[i]:
            p=i
    return i

for i in range(m):
    j=searchmax(*a)
    a[j]/=2

ans=0
for i in range(n):
    ans+=int(a[i])
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = list(map(int,input().split()))

# dp = [[0 for i in range(N)] for _ in range(M)]

# sortedA = sorted(A,reverse=True)

for i in range(M):
    m = max(A)
    A[A.index(m)] = m//2

sum(A)

Submission status: Wrong Answer

Solution code:
# from bisect import bisect_left
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

resid = M
i = 0
pi = 0
pif = True
while resid:
    A[i] //= 2
    resid -= 1
    if i < N-1 and A[i] < A[i+1]:
        if pif:
            pi = i
            pif = False
        i += 1
    else:
        i = pi
        pif = True

print(sum(A))

Submission status: Wrong Answer

Solution code:
import math
n, m = map(int, input().split())
a = list(map(float, input().split()))
a.sort()
print(a)
for _ in range(m):
  a[a.index(max(a))]/= 2

sum = 0
for i in range(len(a)):
     sum += int(math.floor(a[i]))
print(sum)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    inf=10**15
    n,m=map(int, input().split())
    aa=list(map(int, input().split()))
    dp=[[inf]*(m+1) for _ in range(n+1)]
    dp[0][0]=0
    for i,a in enumerate(aa):
        for j in range(m):
            pre=dp[i][j]
            if pre>=inf:continue
            for k in range(m-j+1):
                nj=j+k
                price=int(a/(2**k))
                dp[i+1][nj]=min(dp[i+1][nj],pre+price)
                if price==0:break
    print(min(dp[n]))

main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
while m>0:
  a[0]/=2
  m-=1
  a.sort(reverse=True)
for i in range(n):
  a[i]=round(a[i])
print(sum(a))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
d = {}

def solve(N, M, A, cur, remain):
  if cur == N:
    return 0
  else:
    if not (cur, remain) in d:
      a = A[cur]
      tmp = 10**10
      for i in range(remain+1):
        tmp = min(tmp, solve(N, M, A, cur+1, remain-i)+a//(2**i))
      d[(cur, remain)] = tmp
    return d[(cur, remain)]
n, m = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, m, a, 0, m))

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
lst = [int(i) for i in input().split()]
for x in range(m):
    lst.sort()
    m //= 2
print(sum(lst))

Submission status: Wrong Answer

Solution code:
import numpy as np
N,M=map(int, input().split())
A=np.array(list(map(int, input().split())))
for i in range(M):
    A[A.argmax()]=A[A.argmax()]//2
sum(A)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
use = 0
for i in range(N):
    X = max(A)
    Y = A.index(max(A))
    for j in range(M):
        if use == M:
            break
        if A[Y]!= max(A):
            break
        else:
            A[Y] = A[Y]//2
            use += 1
for i in range(N):
    ans += A[i]
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
A = np.array(list(map(int, input().split())))

for i in range(M):
  A.sort(kind='mergesort')
  A[-1] /= 2

print(np.sum(np.floor(A)))

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
from math import floor
N, M = map(int, input().split())
A = []
for a in map(int, input().split()):
    heappush(A, -a)
    
for _ in range(M):
    l = heappop(A) / 2
    heappush(A, l)
    
sum([floor(-heappop(A)) for _ in range(N)])

Submission status: Wrong Answer

Solution code:
# from bisect import bisect_left
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

resid = M
i = 0
pi = 0
pif = True
while resid:
    A[i] //= 2
    resid -= 1
    if i < N-2 and A[i] < A[i+1]:
        if pif:
            pi = i
            pif = False
        i += 1
    else:
        i = pi
        pif = True

print(sum(A))

Submission status: Wrong Answer

Solution code:
import numpy as np

n,m=map(int,input().split())
a=np.asarray(list(map(float,input().split())),dtype=np.float32)

for i in range(m):
  a=np.sort(a)
  a[n-1]=a[n-1]/2
  
ans=0
for j in range(n):
  ans=ans+int(a[j])

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
while M > 0:
	M -= 1
	A[0] = A[0]//2
	for i in range(1, N):
		if M > 0:
			if A[i] > A[i-1]:
				A[i] = A[i]//2
				M -= 1
			else: break
		else: break
		
print(sum(A))

Submission status: Wrong Answer

Solution code:
import heapq as hq
n,m = map(int,input().split())

ls = list(map(int,input().split()))
ls = [-1*a for a in ls]

hq.heapify(ls)

for _ in range(m):
  t = -1*hq.heappop(ls)
  hq.heappush(ls,t//2*(-1))
  
print(sum(ls))

Submission status: Wrong Answer

Solution code:
N, M = [int(x) for x in input().split()]
A =  sorted([int(x) for x in input().split()])
B = A[M+1:]
A = A[:M+1]
for i in range(M):
  t = A.index(max(A))
  A[t] = A[t]//2
print(sum(A)+sum(B))

Submission status: Wrong Answer

Solution code:
import copy
import heapq

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt


n,m = ips()
a = iprow()
a.sort(reverse=True)
#print(a)
heapq.heapify(a)
b = _heappop_max(a)
_heappush_max(a, b)
for i in range(m):
    b = _heappop_max(a)
    #print(b, a)
    b//=2
    _heappush_max(a,b)
print(sum(a))

Submission status: Wrong Answer

Solution code:
n, m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()

for i in range(m):
    a[-1] //= 2
    print(a[-1])
    a.sort()
print(sum(a))

Submission status: Wrong Answer

Solution code:
import math

n,m = map(int,raw_input().split())
a = map(int,raw_input().split())
a = sorted(a, reverse=True)
b = [0]*n
c = [0]*n
for i in xrange(n):
	b[i] = math.log(a[i],2)
coup = m
while coup > 0:
	for i in xrange(n):
		if i>0 and b[i-1] >= b[i]:
			break
		else:
			coup -= 1
			c[i] += 1
			b[i] -= 1
			if coup == 0:
				break
res = 0
for i in xrange(n):
	res += (a[i]>>c[i])
print res

Submission status: Wrong Answer

Solution code:
N, M = [int(x) for x in input().split()]
A =  sorted([int(x) for x in input().split()])
B = A[M:]
A = A[:M]
for i in range(M):
  A[A.index(max(A))] = A[A.index(max(A))]//2
print(sum(A)+sum(B))

Submission status: Wrong Answer

Solution code:
import sys
import collections
import copy
import math
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
N,M =map(int,input().split())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
count = 0
while count != M:
    for i in range(len(A)):
        chk =A[0]//2
        if A[i] >= chk:
            A[i] = A[i]//2
            count += 1
            if count == M:
                break
        else:
            A.sort(reverse=True)
            break
print(sum(A))

Submission status: Wrong Answer

Solution code:
import bisect

n,m=map(int,input().split())
a=[int(i) for i in input().split()]
a.sort(reverse=True)

for i in range(m):
    check=a[0]//2
    a.sort(reverse=True)
print(sum(a))

Submission status: Wrong Answer

Solution code:
from heapq import heapify, heapreplace

n, m = list(map(int, input().split()))
aaa = list(map(int, input().split()))
heapify(aaa)

for _ in range(m):
    heapreplace(aaa, aaa[0] // 2)

print(sum(aaa))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = sorted(map(int,input().split()))

for i in range(m):
    a[-1] //= 2
    
    if 1 < len(a) and a[-2] > a[-1]:
        a = sorted(a)
    
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = sorted(map(int,input().split()))

for i in range(m):
    a[-1] //= 2
    a = sorted(a)
    
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = sorted(map(int,input().split()))

for i in range(m):
    a[-1] //= 2
    a = sorted(a)
    
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
for _ in range(m):
  a[a.index(max(a))] /= 2
for i in range(n):
  a[i] = int(a[i])
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
  a.sort()
  a[-1]=a[-1]//2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
A.sort(reverse=True)

for m in range(M):
    A[0] = A[0]//2
    A.sort(reverse=True)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left as bs
N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

while M > 0:
  i = A.pop(-1) // 2
  A.insert(bs(A, i), i)
  M -= 1

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
for _ in range(m):
    a = A[-1]//2
    A=A[:-1]
    bisect.insort(A,a)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
for _ in range(m):
    A[-1]=A[-1]//2
    A.sort()

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
  a.sort()
  a[-1] /= 2
  #print(a)
for i in range(n):
  a[i] = math.floor(a[i])
#print(a)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
from heapq import heapify, heappop, heappush
dis = []
for k in range(N):
  dis.append((-(A[k]-A[k]//2), k, 0))
heapify(dis)
while M:
  M -= 1
  item = heappop(dis)
  index = item[1]
  cnt = item[2] + 1
  discount = A[index]//pow(2, cnt) - A[index]//pow(2, cnt+1)
  heappush(dis, (-discount, index, cnt))

ans = 0
while dis:
  item = dis.pop()
  ans += A[item[1]]//pow(2, item[2])

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from bisect import *
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))

for m in range(M):
  A[-1]//=2
  A.insert(bisect_left(A,A[-1]),A[-1])
  A.pop()
  
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))

for m in range(M):
  A[-1]//=2
  A = sorted(A)
  
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
for _ in range(m):
    a=sorted(a,reverse=True)
    a[0]//=2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
for i in range(K):
  A[0] = int(A[0]/2)
  A.sort(reverse=True)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
import bisect
for i in range(M):
    bisect.insort(A,A[-1]//2)
    A.pop(-1)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
import bisect
for i in range(M):
    bisect.insort(A,A[-1]/2)
    A.pop(-1)
for i in range(N):
    A[i] = int(A[i])
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))

while m > 0:
    idx = a.index(max(a))
    if a[idx] == 0:
        break
    a[idx] = a[idx] // 2
    m -= 1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse = True)

cnt = [[a[i]] for i in range(n)]

for i in range(n):
    while 1:
        a[i] = a[i] // 2
        cnt[i].append(a[i])
        if a[i] == 0:
            break
while m > 0:
    max_num = [cnt[i][0] for i in range(n)]
    max_index = max_num.index(max(max_num))
    if cnt[max_index][0] == 0:
        break
    del cnt[max_index][0]
    m -= 1
max_num = [cnt[i][0] for i in range(n)]
print(sum(max_num))

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))

for i in range(1, m+1):
    a.sort()
    a[-1] = a[-1] // 2
    if sum(a) == 0:
        break
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))

log_a = [math.log2(x) for x in a]
if sum(log_a) < m:
    print(0)
else:
    for i in range(1, m+1):
        a.sort()
        a[-1] = a[-1] // 2
    print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))

for i in range(m):
  a.sort()
  a[n-1]=a[n-1]//2
  
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(m):
    a[n-1]=a[n-1]/2
    a.sort()
for i in range(n):
    a[i]=int(a[i]//1)
print(sum(a))