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: 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 = list(map(int, input().split()))
A = list(map(int, input().split()))
for m in range(M):
    A = sorted(A)
    A[N-1] = int(A[N-1]/2)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

a = sorted(a)
for i in range(m):
    a_ = int(a[n-1]//2)
    a.pop(n-1)
    bisect.insort(a, a_)
    
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import add

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

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

print(reduce(add, alist))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = numpy.array(list(map(int, input().split())))
for _ in range(m):
    b = numpy.argmax(a)
    a[b] = a[b]//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(reverse=True)

B = [A[0]]
A.pop(0)
for i in range(M):
    if len(A) == 0 or B[0] >= A[0]:
        B[0] //= 2
    else:
        B.append(A[0] // 2)
        A.pop(0)
    B.sort(reverse=True)
    if B[0] == 0:
        break
        
ans = 0
for i in range(len(A)):
    ans += A[i]
for i in range(len(B)):
    ans += B[i]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int,input().split(' '))
A_i = list(map(int,input().split(' ')))
Amax = 0

for i in range(M):
    A_max = max(A_i)
    ind = A_i.index(A_max)
    A_i[ind] = A_i[ind]//2
total = sum(A_i)
print(total)

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in range(m):
    maximum = max(alist)
    chnm = int(alist.index(maximum))
    alist[chnm] = alist[chnm]/2

print( sum([ math.floor(alist[i]) for i in range(n) ]))

Submission status: Time Limit Exceeded

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

for i in range(m):
    s=a.index(max(a))
    a[s]=a[s]//2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect
import math
N, M = [int(item) for item in input().rstrip().split()]
As = sorted([float(item) for item in input().rstrip().split()])
for i in range(M):
    _t = As.pop()
    bisect.insort_right(As, _t/2)
    
_sum = sum([math.floor(item) for item in As])
print(_sum)

Submission status: Time Limit Exceeded

Solution code:
import sys
import copy
import math
import bisect

def dictCount(str):
    dict = {}


if __name__ == '__main__':
    n,m= map(int, input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    half = a[n//2]
    for i in range(m):
        max = a.pop(n-1)
        max = max //2
        if max < half:
            bisect.insort_left(a, max)
        else:
            bisect.insort_right(a, max)
    sum = 0
    for i in a:
        sum = sum+i
    print(sum)

Submission status: Time Limit Exceeded

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

A = np.trunc(A)
print(int(A.sum()))

Submission status: Time Limit Exceeded

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

for i in range(n[1]):
    a[a.index(max(a))] = a[a.index(max(a))]//2 
print(sum(a))

Submission status: Time Limit Exceeded

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

for _ in range(m):
    maxindex = a.index(max(a))
    a[maxindex] = int(a[maxindex] / 2)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a =list( map(int,input().split()))
a_new= sorted(a)[::-1]

while m	> 0:
    if n == 1:
        a_new[0] =	int(a_new[0]/2**m)
        break

    b =	int(a_new[0]/a_new[1])	
    if m-b > 0:
        a_new[0] = int(a_new[0] / 2**b)
        a_new= sorted(a_new)[::-1]
        m -= b
    else:
        a_new[0] = int(a_new[0] / 2**m)
        break

print(sum(a_new))

Submission status: Time Limit Exceeded

Solution code:
#D
n, m = map(int,input().split())
a = list(map(int,input().split()))
i = 0
a.sort(reverse=True)
if n == 1:
    a[0] = a[0]//(2**m)
else:
    while i < m:
        tmp = a[0]
        second = a[1]
        p = min(m - i, max(1, (tmp / second) **.5//1))
        a[0]=(tmp//(2**p))
        a.sort(reverse=True)
        i += p
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[-1] = A[-1]//2
  for j in range(N-1):
    if A[N-1-j] >= A[N-1-j-1]:
      continue
    else:
      temp = A[N-1-j]
      A[N-1-j] = A[N-1-j-1]
      A[N-1-j-1] = temp
      if A[N-1-j-1] <= A[N-1-j]:
        continue
      
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

s = input().split()
# N = int(s[0])
# M = int(s[1])
A = np.array(list(map(int, input().split())))

for i in range(int(s[1])):
    # j = A.index(max(A))
    # j = A.argmax()
    A[A.argmax()] //= 2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
from bisect import insort


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    As = [int(x) for x in stdin.readline().rstrip().split()]
    As.sort()
    for _ in range(M):
        x = As[-1] / 2
        insort(As, x)
        del As[-1]
    sum_ = 0
    for x in As:
        sum_ += int(x)
    print(sum_)


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import bisect


def main():
    N, M = map(int, input().split())
    As = [int(i) for i in input().split()]

    As.sort()
    checkt_used = 0
    while checkt_used <M:
        checkt_used+=1
        if not N == 1:
            takai = As.pop()
            takai //= 2
            b_takai = As[-1]
            while checkt_used<M and b_takai<takai:
                takai//=2
                checkt_used+=1
            bisect.insort_right(As, takai)
        else:
            As[0] //= 2
    print(sum(As))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math

nm = input()
a = input()

nm = nm.split()
n = int(nm[0])
m = int(nm[1])
a = a.split()
a = [int(x) for x in a]

for i in range(m):
    index = np.argmax(a)
    a[index] = math.floor(a[index]/2)

output=0
for i in range(n):
    output += a[i]

print(output)

Submission status: Time Limit Exceeded

Solution code:
s=list(input().split())
N=int(s[0])
M=int(s[1])
count=0
total=0
a = list(input().split())
for i in range(N):
  a[i]=int(a[i])
while(count<M):
  a[a.index(max(a))]=a[a.index(max(a))]//2
  count+=1

for i in range(N):
  total=total+a[i]
  
print(total)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

n, m = map(int, input().split())
l = [int(n) for n in input().split()]

for j in range(m):
    i = l.index(max(l))
    k = int(l.pop(i)/2)
    if k > 0:
        l.append(k)
    if len(l) == 0:
        break
    
print(sum(l))

Submission status: Time Limit Exceeded

Solution code:
import sys
import heapq
n, m = map(int, sys.stdin.readline().split())
A = list(map(lambda x:-int(x), sys.stdin.readline().split()))
heapq.heapify(A)

for j in range(m):
    A[0] = int(A[0]/2)
    heapq.heapify(A)

print(-sum(A))

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[54]:


#import copy
import numpy as np

N, M = map(int, input().split())
As = np.array(sorted(list(map(int, input().split())), reverse=True))
"""
3 3
2 13 8

4 4
1 9 3 5
"""


# In[56]:


As[:9] = As[:9]


# In[57]:


As[0] = As[0] // 2
for i in range(1, M):
    As[:i+1] = np.sort(As[:i+1])[::-1]
    As[0] = As[0] // 2


# In[39]:


#print(As)
print(sum(As))


# In[ ]:

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n, m = map(int, input().split())

#a_list = np.array(list(map(int, input().split())))                                      

a_list = np.array(sorted(list(map(int, input().split())), reverse=True))
b_list = a_list[:m]
c_list = a_list[m:]

for i in range(m):
    j = np.argmax(b_list)
    b_list[j] = b_list[j] // 2

print(sum(b_list)+sum(c_list))

Submission status: Time Limit Exceeded

Solution code:
import math
N, M = map(int,input().split())
A = list(map(int,input().split()))
ans = sum(A)
for i in range(M):
    ans = ans - max(A) + math.floor(max(A)/2)
    A.append(math.floor(max(A)/2))
    A.remove(max(A))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n_items, n_vouchers = [int(x) for x in input().split(" ")]
prices = [int(x) for  x in input().split(" ")]
prices = np.array(prices, dtype="uint64")

for i in range(n_vouchers):
    prices[np.argmax(prices)] = prices[np.argmax(prices)] // 2

print(np.sum(prices))

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):
    new = a[-1] // 2
    l = 0
    r = n - 2
    mid = (l + r) // 2
    while l <= r:
        mid = (l + r) // 2
        guess = a[mid]
        if guess == new:
            break
        if guess > new:
            r = mid - 1
        else:
            l = mid + 1
    a.insert(mid,new)
    a = a[:-1]

print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
input = sys.stdin.readline
n , m = map(int,input().split())
price_li = list(map(int,input().split()))
np_li = np.array(price_li) 
for i in range(m):
    np_li[np_li.argmax()] = np.amax(np_li) // 2
print(sum(np_li))

Submission status: Time Limit Exceeded

Solution code:
import math

n,m = map(int,input().split())
A = list(map(int,input().split()))
def calc(n):
  return math.floor(n)
  
for i in range(m):
  A.sort(reverse=True)
  A[0] /= 2 
A = map(calc,A)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = [int(x) for x in input().split(' ')]

for c 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()))
for i in range(1,m+1):
  l = a.index(max(a))
  a[l] = a[l] // 2
print(sum(a))

Submission status: Time Limit Exceeded

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

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

lst.sort(reverse=True)

for i in range(M):
    a = lst.pop(0) // 2 
    lst.append(a)
    lst.sort(reverse=True)
print(sum(lst))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n,m = map(int,input().split())
a_list = list(map(int,input().split()))
a_array = np.array(a_list)
for i in range(m):
    max_index = np.argmax(a_array)
    a_array[max_index] //= 2
print(np.sum(a_array))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int, input().split())
A = sorted(map(int, input().split()),reverse=1)
while m>0:
    i = 0
    A[i] //= 2
    if n==1:
        m -= 1
        continue
    while A[i]<A[i+1]:
        A[i],A[i+1]=A[i+1],A[i]
        i += 1
        if i==n-1:
            break
    m -= 1
print(sum(A))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:

# coding: utf-8

# In[5]:


import numpy as np


# In[12]:


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


# In[16]:


for i in range(M):
    A[A.argmax()]/=2


# In[17]:


print(A.sum())

Submission status: Time Limit Exceeded

Solution code:
import sys
 
input = sys.stdin.readline
 
 
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a=sorted(a,reverse=True)
    for i in range(m):
        a[a.index(max(a))] //= 2
    print(sum(a))
 
 
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
els = list(map(int, input().split()))
for j in range(m):    
    max_ind = 0 
    max_el = 0
    for i in range(n):
        if els[i] > max_el:
            max_el = els[i]
            max_ind = i
    els[max_ind] = els[max_ind]//2
print(sum(els))

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[a.index(max(a))] = math.floor(a[a.index(max(a))] / 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[a.index(max(a))] //= 2

print(sum(a))

Submission status: Time Limit Exceeded

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

a = [int(i) for i in input().split()]

a = sorted(a)[::-1]

while m>=1:
  a[0] //= 2
  a = sorted(a)[::-1]
  m -= 1

print(sum(a))

Submission status: Time Limit Exceeded

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

for _ 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(list([int(x) for x in input().split()]), reverse=True)

for i in range(m):
    a[0] = a[0] // 2
    if n > 1:
        if a[0] < a[1]:
            a = sorted(a, reverse=True)
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):
    b = a.index(max(a))
    a[b] = int(a[b]/2)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
def main():

  n,m=map(int,input().split())
  a=list(map(int,input().split()))
  for i in range(m):
    a.sort(reverse=True)
    a[0]=a[0]//2
  print(sum(a))
  
main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    import bisect
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    for divcnt in range(M):
        tmp = A.pop()//2
        bisect.insort(A,tmp)
    print(sum(A))
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin
import math

# 標準入力をスペースで区切って、intに変換 listに収納
int_list  = [int(x) for x in stdin.readline().rstrip().split()]
A_list = [int(x) for x in stdin.readline().rstrip().split()]

N = int_list[0]
M = int_list[1]

A_list.sort(reverse=True)

for i in range(M):
    tmp_max = max(A_list)
    for j in range(len(A_list)):
        if A_list[j] == tmp_max:
            A_list[j] = A_list[j] // 2
            break


print(sum(A_list))

Submission status: Time Limit Exceeded

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

for i in range(M):
  A[A.index(max(A))] = max(A)//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[-1] //= 2
ans = sum(A)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m = list(map(int,input().split()))
lis = []
lis = list(map(int,input().split()))
nu_sum = 0
for i in range(n):
    nu_sum += lis[i]
for i in range(m):
    if nu_sum <= 0:
        break
    tmp_max = max(lis)
    lis[lis.index(tmp_max)] = tmp_max //2
    if tmp_max % 2 == 0:
        nu_sum -= tmp_max/2
    else:
        nu_sum -= tmp_max // 2 + 1
print(int(nu_sum))

Submission status: Time Limit Exceeded

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

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

for w in range(M):
    A.sort()
    A[N-1]=A[N-1]/2
    #print(A)

B=list(map(int, A))
#print(B)
print(sum(B))

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 = sorted(A, reverse=True)
    A[0] = int(A[0] / 2)
    
from functools import reduce

print(reduce(lambda x, y:x + y, A))

Submission status: Time Limit Exceeded

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

for _ in range(M):
    buf=A.index(max(A))
    A[buf]=A[buf]//2
print(int(sum(A)))

Submission status: Time Limit Exceeded

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


if __name__ == "__main__":
    test()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, M = map(int, input().split())
a = list(map(int, 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:
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
tmp = A.pop(-1)
index = 0
for _ in range(M):
  tmp //= 2
  if tmp == 0:
    if len(A) == 0:
      break
    tmp = A.pop(-1)
  if len(A) > 1 and tmp < A[-1]:
    A.append(tmp)
    tmp = A.pop(-2)
    A.sort()
A.append(tmp)

print(sum(A))

Submission status: Time Limit Exceeded

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

c=0
i=0

for i in range(M):
    idx=A.index(max(A))
    A[idx]=A[idx]//2
    c+=1


print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
input = sys.stdin.readline

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

for _ in range(M):
    A[np.argmax(A)] >>= 1

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
N,M=map(int,input().split())
A=[int(_) for _ in input().split()]
A.sort()

for m in range(M):
    a=A.pop(-1)//2
    insert_index = bisect.bisect_right(A,a)
    A.insert(insert_index,a)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(a)
for i in range(m):
    a[-1] //= 2
    popped = a.pop(-1)
    bisect.insort_right(a, popped)
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)

for i in range(m):
    a[0] = 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()
for i in range(m):
    a[-1] //= 2
    a.sort()
print(sum(a))

Submission status: Time Limit Exceeded

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

sorted_S = [i for i in reversed(sorted(S))]
max_index = 0

for i in range(M):

    sorted_S[0] = int(sorted_S[0]/2)
    i = 0
    for j in range(1, N):
        if sorted_S[i] < sorted_S[j]:
            sorted_S[i], sorted_S[j] = sorted_S[j], sorted_S[i]
            i += 1
        else:
            break

print(sum(sorted_S))

Submission status: Time Limit Exceeded

Solution code:
N,M = [int(i) for i in input().split()]
data = [int(i) for i in input().split()]
data.sort(reverse = True)
#print(data)
while M != 0:
    x = max(data)
    data[data.index(x)] //= 2
    M -= 1
    #print(data)

print(sum(data))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, M =map(int, input().split())
A = np.array(list(map(int, input().split())))
#print(A)
for i in range(M):
    A = np.sort(A)[::-1]
    A[0] = A[0]/2
    #print(A)

A = np.trunc(A)
print(int(A.sum()))

Submission status: Time Limit Exceeded

Solution code:
s = input().split()
n = int(s[0])
m = int(s[1])
a_i = input().split()
a_i = [int(i) for i in a_i]
a_i.sort(reverse=True)
for j in range(m):
  discount = int(a_i[0] / 2)
  a_i[0] = discount
  a_i.sort(reverse=True)
print(sum(a_i))

Submission status: Time Limit Exceeded

Solution code:
def do():
    N, M = map(int,input().split())
    A = list((map(int,input().split())))
    A.sort()
    A.reverse()
    for i in range(M):
        A[0] = A[0]//2
        for k in range(N-1):
            if A[k] < A[k+1]:
                A[k], A[k+1] = A[k+1], A[k]
            else:
                break
    print(sum(A))
    
    
if __name__ == '__main__':
    do()

Submission status: Time Limit Exceeded

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

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

count = 0

while m>count:
    if n == 1:
        a_list[0] = a_list[0] // 2
        count += 1
    else:
        a_list.sort(reverse=True)
        a_list[0] = a_list[0] // 2
        count += 1
        if a_list[0] >= a_list[1]:
            a_list[0] = a_list[0] // 2
            count += 1
        
print(sum(a_list))

Submission status: Time Limit Exceeded

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

a = sorted(l, reverse=True)

idx = 0
for i in range(m):
    a[idx] = a[idx]//2
    max_val = max(a)
    idx = a.index(max_val)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

N, M = map(int, input().split())
B = [int(x) for x in input().split()]
A = sorted(B)

# print(A)
for i in range(M):
    value = A.pop(N-1)
    value = value//2
    bisect.insort_left(A, value)
# print(A)
ans = sum(A)
print(ans)

Submission status: Time Limit Exceeded

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

for _ in range(M):
    A.sort(reverse=True)
    A[0] //= 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[A.index(max(A))] //= 2
print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))
for m in range(M):
  max_=max(a)
  a.remove(max_)
  a.append(max_//2)
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

def waribiki(X,Y):
    return X//(2**Y)

while M>0:
    A.sort(reverse=True)
    A[0] = waribiki(A[0],1)
    M -= 1

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline
# n = int(input())
n, m = map(int, input().split())
a = input()
a_list = [int(x.strip()) for x in a.split()]

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

print(sum(a_list))

Submission status: Time Limit Exceeded

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

A.sort(reverse=True)
#print(A)

for i in range(M):
    idx = A.index(max(A))

    A[idx] = int(A[idx] / 2.0)
#    A.sort(reverse=True)

ans = 0
for i in range(N):
    ans += A[i]

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = [int(x) for x in input().split(' ')]

for c in range(m) :
        a.sort()
        a.reverse()
        a[0] = a[0] // 2

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
A.sort()
cost=sum(A)
for i in range(M):
    if A[N-1]%2==0:
        cost-=A[N-1]//2
    else:
        cost-=A[N-1]//2+1
    A[N-1]=A[N-1]//2
    if A[N-2]>A[N-1]:
        A.sort()
print(cost)

Submission status: Time Limit Exceeded

Solution code:
import math

n, m = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for i in range(n):
  if a[i] in d:
    l = d[a[i]]
    l.append(i)
    d[a[i]] = l    
  else:
    d[a[i]] = [i]

for i in range(m):
  b = max(a)
  li = d[b]
  a[li[0]] = b/2
  if b/2 in d:
    l = d[b/2]
    l.append(li[0])
    d[b/2] = l
  else:
    d[b/2] = [li[0]]
  del li[0]
  d[b] = li

ans = 0
for i in a:
  ans += math.floor(i)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
A=[int(n) for n in input().split()]
A.sort()
def insert_sort(arr):
    for i in range(1, len(arr)):
        j = i - 1
        ele = arr[i]
        while arr[j] > ele and j >= 0:
            arr[j + 1] = arr[j]
            j -= 1
        arr[j + 1] = ele
    return arr
        
for _ in range(M):
    A[-1] = A[-1]//2
    A = insert_sort(A)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# D - Powerful Discount Tickets
inputNum = list(map(int, input().split()))
N = inputNum[0]
M = inputNum[1]

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

for i in range(M):
    A[A.index(max(A))] //= 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):
    maxa = max(a)
    if maxa == 0:
        break
    a[a.index(maxa)] = maxa // 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect
import sys

inf = sys.maxsize
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

for i in range(M):
    x = A.pop(N-1)
    if x == 0:
        break
    x = x // 2
    A.insert(bisect.bisect_left(A, x), x)
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(reverse=True)
    A[0] = A[0]//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(reverse=True)
    a[0]=int(a[0]/2)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline

S = list(map(int, input().split()))
N = S[0]
M = S[1]
A = list(map(int, input().split()))


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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np
n, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a = np.array(a)

for i in range(m):
    a[np.argmax(a)] = math.floor(max(a)/2)
    if max(a)==0:
        break

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import sys

A = [int(x) for x in input().split()]
#print(AB)
N = A[0]
M = A[1]
#print(N)
#print(M)
B = [int(x) for x in input().split()]
#print(B)

for i in range(M):
    max_index = B.index(max(B))
    B[max_index] = int(B[max_index] / 2)
    #print(B)
print(sum(B))

Submission status: Time Limit Exceeded

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

A.sort()
tmp = A.pop(-1)
index = 0
for _ in range(M):
  tmp //= 2
  if N > 1 and tmp < A[-1]:
    A.append(tmp)
    tmp = A.pop(-2)
    A.sort()
A.append(tmp)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# sys.stdin.readline()
import sys
input = sys.stdin.readline
import math

N,M = (int(x) for x in input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    
n,m=map(int,input().split())

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



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

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a=sorted(a,reverse=True)
    for i in range(m):
        a[a.index(max(a))] //= 2
    print(sum(a))


if __name__ == "__main__":
    main()

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 i in range(M):
    A = sorted(A, reverse=True)
    A[0]=A[0]//2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N, M, *A, = map(int, open(0).read().split())
for _ in range(M):
    a = A.index(max(A))
    A[a] = A[a] // 2
print(sum(A))