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())
import sys
input = sys.stdin.readline
a = list(map(int, input().split()))

from itertools import combinations_with_replacement
from itertools import groupby

ans = float("inf")
x =sum(a)

for i in combinations_with_replacement(range(n), m):
  m = x
  lis = list(i)
  for j, k in groupby(lis):
    m -= a[j]
    m += a[j]//(2**len(list(k)))
  ans = min(ans, m)
  
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
import bisect
N,M=map(int,input().split())
l=deque(list(map(int,input().split())))
sl=sorted(l)
for i in range(M):
	sl[N-1]=sl[N-1]//2
	tmp=sl.pop()
	bisect.insort(sl, tmp) 
else:
	print(sum(sl))

Submission status: Time Limit Exceeded

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

# Alistの値段の高いモノから割引券を使った方がよい
while M > 0:
    max_index = Alist.index(max(Alist))
    Alist[max_index] = Alist[max_index]//2
    M = M - 1
print(sum(Alist))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
L = list(map(int,input().split()))
for j in range(M):
    idx = L.index(max(L))
    L[idx] //=  2
    
print(sum(L))

Submission status: Time Limit Exceeded

Solution code:
import math
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
A=sorted(list(map(int, input().split())),reverse=True)
for i in range(M):
  A[0]=A[0]/2
  for j in range(N-1):
    if A[j]<A[j+1]:
      a=A[j]
      A[j]=A[j+1]
      A[j+1]=a
    else:
      break
  #print(A)
ans=0
for i in range(N):
  ans+=math.floor(A[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
for i in range(m):
    b = a.pop()
    b = b//2
    a.insert(bisect.bisect_left(a,b),b)
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())))
for i in range(m):
    a[np.argmax(a)] /= 2
b = [abc // 1 for abc in a]
print(np.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.sort()
    a[n-1] //= 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()]
ans = sum(a)
a.sort()
a.reverse()
k = 0
for i in range(m):
    ans -= -(-a[k]//2)
    if ans == 0:
        break
    a[k] = a[k]//2
    k = max(enumerate(a),key = lambda x:x[1])[0]
print(ans)

Submission status: Time Limit Exceeded

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

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

for _ in range(M):
    a = max(enumerate(A), key=lambda x: x[1])

    A[a[0]] = a[1] // 2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import os

N,M = (int(x) for x in input().split())
list = list(map(int,input().split()))

ans = 0
for i in range(0,M):
    a = list.index(max(list))
    list[a] = list[a]//2
for j in list:
    ans += j
print(ans)

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())))

for i in range(0,M):
    max_index = np.argmax(A)
    tmp = A[max_index]
    tmp = (tmp // 2)
#    print(A[max_index])
    A[max_index] = tmp
 #   print(A[max_index])

lis = A.tolist()
print (sum(lis))

Submission status: Time Limit Exceeded

Solution code:
input_line=list(map(int,input().split()))
N=input_line[0]
M=input_line[1]

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


for n in range(M):
    A_lis[A_lis.index(max(A_lis))] = int(A_lis[A_lis.index(max(A_lis))]/2)

print(sum(A_lis))

Submission status: Time Limit Exceeded

Solution code:
import math
import bisect

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
if N > M:
  A_small = A[0:N - M]
  A = A[N - M:]
else:
  A_small = []

for i in range(M):
  if (len(A) > 1 and A[-1] < A[-2]):
    a = A.pop(-1)
    bisect.insort(A, a)
  A[-1] /= 2.0

A.extend(A_small)
amount = 0
for a in A:
  amount += math.floor(a)
print(amount)

Submission status: Time Limit Exceeded

Solution code:
get1 = list(map(int, input().split()))
get2 = list(map(int, input().split()))
 
N = get1[0]
M = get1[1]

count = 0

while M > 0:
  get2[get2.index(max(get2))] = get2[get2.index(max(get2))] // 2
  M -= 1
  
print(sum(get2))

Submission status: Time Limit Exceeded

Solution code:
import math

def main():
    #tmp = input()
    tmp = input()
    tmp_s = [int(x.strip()) for x in tmp.split(' ')]
    N = tmp_s[0] #num of stuff
    M = tmp_s[1] #num of discount
    A_tmp = input()
    A = [int(x.strip()) for x in A_tmp.split(' ')]
    for i in range(M):
        flag = A.index(max(A))
        A[flag] = A[flag]/2
    
    S = 0
    for x in A:
        S += math.floor(x)

    print(S)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
LL = [int(i) for i in input().split()]
N = LL[0]
M = LL[1]

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


for c in range(M):
    A_price = sorted(A_price,reverse=True)
    A_price[0] = A_price[0] //2
    
print(sum(A_price))

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 = map(int,input().split())
a = list(map(int,input().split()))
for i in range(m):
         aa = max(a)
         a.append(aa//2)
         a.remove(aa)
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# sys.stdin.readline()
import sys
import time
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)

# t1 = time.time()
for i in range(M):
    a = max(A) // 2
    j = A.index(max(A))
    A[j] = a
    # A[0] = A[0]//2
    # A.sort(reverse=True)
    if sum(A) <1:
        break

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
A = list(map(int, input().split()))
# A = list(map(lambda x: int(x/2), A))

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

print(sum(A))

Submission status: Time Limit Exceeded

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

# In[69]:


#import copy
import numpy as np

N, M = map(int, input().split())
As = np.sort(np.array(list(map(int, input().split()))))[::-1]
"""
3 3
2 13 8

4 4
1 9 3 5
"""


# In[70]:


As


# In[71]:


#As[0] = As[0] // 2
#arg = 
arg = 0
argrange = 0
As[arg] = As[arg] // 2
for i in range(1, M):
    argrange = max(arg + 1, argrange)
    arg = np.argmax(As[:argrange+1])
    #print(arg)
    As[arg] = As[arg] // 2
    #As[:i+1] = np.sort(As[:i+1])[::-1]
    #As[0] = As[0] // 2


# In[72]:


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


# In[ ]:

Submission status: Time Limit Exceeded

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

for num in range(M):
    all_price[0] = all_price[0] >> 1
    all_price.sort(reverse=True)

print(sum(all_price))

Submission status: Time Limit Exceeded

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

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

print(int(sum(List)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

while m > 0:
    d = 0
    for i in range(n):
        if i < n-1 and la[i] > la[i+1]:
            if la[i+1] > 0:
                d = la[i] // la[i+1]
            else:
                d = 1
            if d > m:
                d = m
                la[i] = la[i] // (2**d)
            else:
                la[i] = la[i] // (2**d)
            break
        else:
            la[i] = la[i] // 2
            d = 1
            break
    la.sort(reverse=True)
    #print(la)
    #print(d)
    m -= d

print(sum(la))

Submission status: Time Limit Exceeded

Solution code:
import array

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

for i in range(m):
        a[a.index(max(array.array("L", a)))] //= 2

print(sum(a))

Submission status: Time Limit Exceeded

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

top = 0
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:
import bisect
import copy

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
A2 = copy.deepcopy(A[N-M:])

for _ in range(M):
  tmp_a = int(A2[-1]/2)
  del A2[-1]
  A2.insert(bisect.bisect_left(A2,tmp_a),tmp_a)
print(sum(A[:N-M])+sum(A2))

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

s=stdin.readline().rstrip().split()
N=int(s[0])
M=int(s[1])
count=0
total=0

a=stdin.readline().rstrip().split()
for i in range(N):
  a[i]=int(a[i])

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

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

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())))

for i in range(m):
  idx = a.argmax()
  if a[idx] == 0:
    break
  a[idx] //= 2

print(np.sum(a))

Submission status: Time Limit Exceeded

Solution code:
x = map(int,raw_input().split())
n=x[0]
m=x[1]
a = map(int,raw_input().split())

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

a=list(map(int, a))

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)
if len(A) == 1:
    A[0] = A[0] // (2**M)
else:
    while M > 0:
        #割引券なくなるまで
        # index:0 と index:1 を比較して一気に何枚が使う
        m = A[0] // A[1] // 2 + 1
        if m <= M:
            A[0] //= (2**m)
            M -= m
        else:
            A[0] //= (2**M)
            M = 0
        i = 0
        while i < len(A) - 2:
            if A[i] < A[i+1]:
                A[i],A[i+1] = A[i+1],A[i]
                i += 1
            else:
                break
            #order(n)
            #A.sort(reverse=True)
        #print('Hoo')
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
goods, tickets = list(map(int, input().split()))
price = list(map(int, input().split()))

while tickets > 0:
    highest_index = price.index(max(price))
    highest = max(price)
    if not len(price) == 1:
        while highest_index == price.index(max(price)):
            use = 1
            discount = math.floor(price[highest_index] / (2 ** use))
            if discount < highest:
                price[highest_index] = discount
                tickets -= use
            elif discount == 0:
                break
            else:
                use+=1
    else:
        discount = math.floor(price[highest_index] / (2 ** tickets))
        tickets = 0
        price[0] = discount
print(sum(price))

Submission status: Time Limit Exceeded

Solution code:
N, M = (int(i) for i in input().split())
A = [int(i) for i in input().split()]

import numpy as np

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

print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

alist.sort(reverse=True)

if n > 2:
    for i in range(m):
        if alist[0] >= alist[1]:
            alist[0] = alist[0] / 2
        else:
            alist.sort(reverse=True)
            alist[0] = alist[0] / 2
    print(sum([math.floor(alist[i]) for i in range(n)]))

else:
    print(alist[0]//(2**m))

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()
    a[n-1] = a[n-1]//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 = sorted(A, reverse=True)

for i in range(M):
    s = A_sorted[:i+1]
    A_sorted[A_sorted.index(max(s))] /= 2 

ans = 0
for i in range(N):
    ans += A_sorted[i]//1
    
print(int(ans))

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    if n == 1:
        a = int(input())
        for i in range(m):
            a //= 2
        print(a)
        exit()

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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n, m = (int(x) for x in input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数liに代入。
ind = 0

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

print(sum(a))

Submission status: Time Limit Exceeded

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

A = np.array(A)
A = sorted(A, reverse=True)

remainM = M
n = 0
if N == 1:
    print(A[0] // (2**M))
else:
    while True:
        A[0] = A[0] // 2
        A = sorted(A, reverse=True)
        remainM = remainM - 1
        if remainM <= 0:
            break
    print(np.sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
_, m = list(map(int, input().split()))
a = np.array(list(map(int, input().split())))

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
import heapq
 
n,m = list(map(int,input().split()))
 
a = list(map(int,input().split()))
 
tmp = 0
 
for i in range(m):
 
        tmp = heapq.nlargest(1,a)
        a.remove(tmp[0])
        a.append(math.floor(tmp[0]/2))
 
 
print(sum(a))

Submission status: Time Limit Exceeded

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

list.sort(A, reverse=True)
#print(A)
for m in range(M):
    tmp = A[0] / 2
    del A[0]
    insindex = N
    for i in range(len(A)):
        if A[i] < tmp:
            insindex = i
            break
    A.insert(insindex, tmp)
for i in range(len(A)):
    A[i] = int(A[i])
    
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M = input().split()
N = int(N)
M = int(M)
price_list = input().split()
 
price_list = list(map(int, price_list))
 
for m in range(M):
  price_list.sort(reverse=True)
  price_list[0] = int(price_list[0] / 2)
print(sum(price_list))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def coupon(i, m, pay):
    if m == 0 or i == n:
        return sum(l[i:])
    for maisuu in range(1, m+1):
        #print("{}に{}まい使う".format(i, maisuu))
        now = l[i] // (2 ** maisuu)
        pay = min(pay, coupon(
            i + 1, m - maisuu, pay) + now)
        if now == 0:
            break

    return pay


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

l = [int(c) for c in input().split()]
l.sort()
l.reverse()
max_pay = sum(l)
# print(l)


print(coupon(0, m, max_pay))

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

Solution code:
N, M = [int(num) for num in input().split(' ')]
A = [int(num) for num in input().split(' ')]

if len(A) == 1:
  print(sum(A)//(2**(M)))
else:
  while M>=1:
    A = sorted(A,reverse=True)
    
    maxval, secondval = A[0], A[1]
    i_maxval, i_secondval = 0, 1
    if maxval == secondval:
      A[i_maxval] = maxval // 2
      M-=1
      if M==0:
        break

      A[i_secondval] = secondval // 2
      M-=1
      if M==0:
        break
        
    else:
      while maxval >= secondval:
        maxval = maxval//2
        M-=1
        if M==0:
          break
        
      A[i_maxval]=maxval

  print(sum(A))

Submission status: Time Limit Exceeded

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

while n != 0:
    a = sorted(a)
    a[-1] = int(a[-1]/2)
    n -= 1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce

N, M = input().split()
N = int(N)
M = int(M)
A = [int(a) for a in input().split()]

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n = list(map(int,input().split()))
a = list(map(int,input().split()))
a = np.array(a)

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

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
A=[float(x) for x in input().split()]
sum=0
A.sort
for i in range(m):
    A[A.index(max(A))]/=2

for x in A:
    sum+=int(x)

print(sum)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
Asorted = sorted(A)
MM = 0
if M+1 >= N:
    MM = N
else:
    MM = M+1
Atop = [Asorted[N-i-1] for i in range(MM)]
for i in range(M):
    Atopmax = Atop.index(max(Atop))
    Atop[Atopmax] = Atop[Atopmax]//2
count = 0
for i in range(N-MM):
    count += Asorted[i]
count += sum(Atop)
print(count)

Submission status: Time Limit Exceeded

Solution code:
def insertion_sort(array):
    n = array[0]
    for i in range(1, len(array)):
        tmp = array[i]
        if array[i] <= n :
            break
        else:
            array[i-1] = tmp
            array[i] = n
            
    return array

n,m = (int(i) for i in input().split()) 
a = [int(i) for i in input().split()]
a.sort(reverse=True)
for i in range(m):
    down = a[0]
    a.remove(down)
    a.insert(0,down//2)
    a = insertion_sort(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.sort()

for _ in range(M):
    a = A.pop()
    a2=a>>1
    bisect.insort_right(A,a2)
    #print(A2)

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):
    maxid = a.index(max(a))
    a[maxid] = a[maxid] // 2
print(sum(a))

Submission status: Time Limit Exceeded

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

obj = input().strip().split(' ')
A_list = map(int, obj)

val_list = sorted(A_list, reverse=True)

can_insert = False
for _ in range(M):
    val = val_list.pop(0) // 2
    for i, v in enumerate(val_list):
        if val >= v:
            val_list.insert(i, val)
            can_insert = True
            break
    if not can_insert:
        val_list.append(val)

print(sum(val_list))

Submission status: Time Limit Exceeded

Solution code:
temp = list(map(int, input().split()))
N = temp[0] #品物の数
M = temp[1] #割引券の枚数
A = list(map(int, input().split())) #品物の値段のリスト
for i in range(M):
  temp = max(A)//2
  del A[A.index(max(A))]
  A.append(temp)
print(sum(A))

Submission status: Time Limit Exceeded

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

def second_large(x):
    y = x.copy()
    y.remove(max(y))
    return max(y)

if N>=2:
  while M>=1:
    fm_n = max(A)
    sm_n = second_large(A)
    div_m = fm_n/sm_n
    i=1
    while 2**(i+1)<=div_m:
      i+=1

    if M>=i:
      A[A.index(max(A))]=fm_n//(2**i)
      M -= i
    else:
      A[A.index(max(A))]=fm_n//(2**M)
      M = 0

  print(sum(A))
else:
  print(A[0]//2**M)

Submission status: Time Limit Exceeded

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

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

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

A = list(map(int, input().split(" ")))
maxs = 0
k = 0
for i in range(M):
    maxs = max(A)
    if maxs == 0:
        print(0)
        sys.exit()
    k = A.index(maxs)
    A[k] = math.floor(A[k] / 2)


print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
NM = input().split(" ")
A_LIST = input().split(" ")
A = []
for i in A_LIST:
    A.append(int(i))

N = int(NM[0])
M = int(NM[1])

A.sort()
for i in range(0, M):
    m = max(A)
    m = m // 2
    A[N-1] = m
    if m >= max(A):
        pass
    else:
        A.sort()
S = 0
for i in A:
    S += i
print(S)

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):
  A.sort(reverse = True)
  A[0] = round(A[0]/2, 2)

print(sum(map(int, A)))

Submission status: Time Limit Exceeded

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

for i in range(0, M) :
  n = A.index(max(A))
  A[n] = A[n] / 2
  
A = list(int(k) for k in A)

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(M):
    A[A.argmax()] //= 2
print(np.sum(A))

Submission status: Time Limit Exceeded

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

pricelist = list(map(int, input().split()))
#moneylist = input().rstrip().split()
#pricelist.append(price)

for i in range(M):
  maxprice = max(pricelist)
  num = pricelist.index(maxprice)
  pricelist[num] = maxprice // 2

print(sum(pricelist))

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
l = map(int,a)
print(sum(l))

Submission status: Time Limit Exceeded

Solution code:
import copy
import sys

sys.setrecursionlimit(1000000000)

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

A.sort(reverse=True)

cnt = []

def f(a,m):
    if m >= M:
        c = sum(a)
        cnt.append(c)
        return

    for j in range(N):
        t = copy.deepcopy(a)
        if t[j] == 0:
            continue
        t[j] = t[j] // 2
        f(t,m+1)

f(A,0)

if len(cnt) == 0:
    cnt.append(0)

print(min(cnt))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
n, m = map(int, input().split())
a = np.array(list(map(int, input().split())))
for i in range(m):
    a[np.argmax(a)] /= 2
b = [math.floor(abc) for abc in a]
# sum = 0
# for i in range(n):
#     sum += math.floor(a[i])
print(np.sum(b))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
[N,M]=list(map(int,input().split()))

A=[""]*N

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

A.sort()
#print(A)

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


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

Submission status: Time Limit Exceeded

Solution code:
import heapq

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

A = [int(i)*(-1) for i in input().split()]



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

# print(sum(A))


for i in range(M):
	heapq.heapify(A)

	min = heapq.heappop(A)
	# 最小値を削除と値を渡す
	# print(A)
	# print(min)

	heapq.heappush(A,int(min/2))
	# print(A)


print(sum(A)*(-1))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

maxim = max(a)
minim = min(a)

while(maxim>minim*2 and m>=1):
    lmax=-1
    maxid=-1
    for i in range(n):
        if(lmax<a[i]):
            lmax=a[i]
            maxid=i
    maxim=lmax
    if(maxim<=minim*2):
        break
    a[maxid] = a[maxid]//2
    m-=1
    if(a[maxid]<minim):
        minim=a[maxid]
        
a.sort()
aa=a
a=[aa[n-1-i] for i in range(n)]
#print(a)

if(m>=1):
    for i in range(m):
        a[i%n] = a[i%n]//2
    

#print(a)
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def swap_sort(lis):
  for i in reversed(range(len(lis))):
    if lis[i-1]>lis[i]:
      lis[i-1], lis[i] = lis[i], lis[i-1]
    else:
      return lis
  return lis


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

a = sorted(a)

for i in range(m):
  #print("====")
  #print(a)
  a[-1] /= 2
  a = swap_sort(a)
  #print(a)
  
a = [int(ai) for ai in a]
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
a=input().split(' ')
b=input().split(' ')
m=int(a[1])
b=[int(x) for x in b]
while m>0:
    x=b.index(max(b))
    b[x]=b[x]/2
    m-=1
print(str(sum([int(x) for x in b])))

Submission status: Time Limit Exceeded

Solution code:
NM = [int(i) for i in input().split(" ")]
As = [int(i) for i in input().split(" ")]
for i in range(int(NM[1])):
    As[As.index(max(As))] = As[As.index(max(As))] // 2
print(sum(As))

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)

if len(A)==1:
    while M>0:
        A.sort(reverse=True)
        A[0] = waribiki(A[0],1)
        M -= 1
    
else:
    while M>0:
        A.sort(reverse=True)
        m=1
        while waribiki(A[0],m) > A[1]:
            m+=1
        else:
            A[0] = waribiki(A[0],m)
        M -= m

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] = int(A[0] / 2)
	A.sort(reverse=True)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# sys.stdin.readline()
import sys
import time
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)

# t1 = time.time()
for i in range(M):
    a = max(A) // 2
    j = A.index(max(A))
    A[j] = a
    # if sum(A) <1:
    #     break

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
I = list(map(int,input().split()))
N = I[0]
M = I[1]
A = list(map(int,input().split()))
for i in range(M):
    num = A.index(max(A))
    A[num] = A[num] / 2
ans = 0
for i in range(N):
    ans += int(A[i])
print(ans)

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 _ in range(m):
    a_tmp = a.pop()
    a_tmp //= 2
    if(len(a)==0):a.append(a_tmp)
    else:
        if(a_tmp >= a[-1]):a.append(a_tmp)
        elif(a_tmp <= a[0]):a.insert(0,a_tmp)
        else:
            index = bisect.bisect_left(a,a_tmp)
            a.insert(index,a_tmp)


print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
get1 = list(map(int, input().split()))
get2 = list(map(int, input().split()))
 
N = get1[0]
M = get1[1]
 
for i in range(M):
  get2[get2.index(max(get2))] = get2[get2.index(max(get2))] // 2

  
print(sum(get2))

Submission status: Time Limit Exceeded

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