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:
#atcorder beginner contest 141
#D powerful discount tickets
import math

goods, tickets = input().split()
goods = int(goods)
tickets = int(tickets)

price = []
total = 0

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

for i in range(tickets):
    max_index = price.index(max(price))
    max_price = math.floor(max(price) / 2)
    price[max_index] = max_price


for i in range(goods):
    total += price[i]

print(total)

Submission status: Time Limit Exceeded

Solution code:
N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
while M>0:
    B=max(A)
    A[A.index(B)]=A[A.index(B)]//2
    M-=1
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
while M>0:
    B=max(A)
    A[A.index(max(A))]=A[A.index(max(A))]//2
    M-=1
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = [int(s) for s in input().split()]
# m回だけ最も大きい数字を2で割る
for i in range(m):
    a[a.index(max(a))] //= 2
print(sum(a[i] for i in range(n)))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = [int(s) for s in input().split()]
# m回だけ最も大きい数字を2で割る
for i in range(m):
    a.sort()
    a[n-1] //= 2
print(sum(a[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()))
a=sorted(a,reverse=True)
import numpy as np
a=np.array(a)
for i in range(M):
  if i>0:
    x=0
    for j in range(N-1):
      if a[0]<a[j+1]:
        x+=1
      elif x>0:
        a0=a[0]
        for k in range(x):
          a[k]=a[k+1]
        #b=a[1:x+1]
        #a[:x]=b
        a[x]=a0
        break
  a[0]=a[0]/2
  
sum=0
for i in range(N):
  sum+=int(a[i])
print(sum)

Submission status: Time Limit Exceeded

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

for i in range(M):
  if i>0:
    x=0
    for j in range(N-1):
      if a[0]<a[j+1]:
        x+=1
      elif x>0:
        a0=a[0]
        for k in range(x):
          a[k]=a[k+1]
        #b=a[1:x+1]
        #a[:x]=b
        a[x]=a0
        break
  a[0]=a[0]/2
  
sum=0
for i in range(N):
  sum+=int(a[i])
print(sum)

Submission status: Time Limit Exceeded

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

for i in range(M):
  if i>0:
    x=0
    for j in range(N-1):
      if a[0]<a[j+1]:
        x+=1
      elif x>0:
        a[:x+1]=sorted(a[:x+1],reverse=True)
        break
  a[0]=a[0]/2
  
sum=0
for i in range(N):
  sum+=int(a[i])
print(sum)

Submission status: Time Limit Exceeded

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

if n == 1:
    print(math.floor(a[0]/2**m))
else:
    while m > 0:
        while a[-1] >= a[-2]:
            a[-1] = math.floor(a[-1]/2)
            m -= 1
        temp = a[-1]
        a.pop(-1)
        a.insert(bisect.bisect_left(a,temp),temp)
    print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
n,a=map(int,input().split())
list=list(map(int,input().split()))
list.sort()
x=0
for i in range(a):
   x = max(list)/2
   x=math.floor(x)
   list.pop()
   list.append(x)
   list.sort()
print(sum(list))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import math
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
item_list = list(map(int, input().split()))

for i in range(M):
    item_list.sort()
    item_list[-1] = math.floor(item_list[-1] / 2)

total = 0
for p in item_list:
    total += p

print(total)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

A.sort()

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

for m in range(M):
    a = A[-1]
    A = A[:-1]

    a //= 2

    for i, x in enumerate(reversed(A)):
        j = len(A) - i - 1
        if x < a:
            A.insert(j+1, a)
            break
    else:
        A = [a] + A

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys

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

A.sort()

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

for m in range(M):
    *A, a = A

    a //= 2

    for i, x in enumerate(reversed(A)):
        j = len(A) - i - 1
        if x < a:
            A.insert(j+1, a)
            break
    else:
        A = [a] + A

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys

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

A.sort()

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

for m in range(M):
    *A, a = A

    a //= 2

    for i, x in reversed(list(enumerate(A))):
        if x < a:
            A.insert(i+1, a)
            break
    else:
        A = [a] + 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()

for m in range(M):
    if len(A) == 1:
        A[0] //= 2
        continue

    *A, a = A

    a //= 2

    for i, x in reversed(list(enumerate(A))):
        if x < a:
            A.insert(i+1, a)
            break
    else:
        A = [a] + 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 i in range(m):
    x = max(a)
    i = a.index(x)
    x_b = x//2
    a[i] = x_b

print(sum(a))

Submission status: Time Limit Exceeded

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

def discount(items):
    x = max(items)
    i = items.index(x)
    x_b = x//2
    items[i] = x_b
    return items

for i in range(m):
    a = discount(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)
for _ in range(M):
  for i in range(N):
    if A[i] == max(A):
      A[i] = A[i]/2
      break

  
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 _ in range(M):
  mx = max(A)
  idx =  A.index(max(A))
  A[idx] = mx/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())
item = list(map(int,input().split()))
 
item.sort(reverse=True)
s = 0
 
while s == 0:
    for i in range(n):
        if i == 0:
            item[i] = int(item[i]/2)
            m -= 1
            temp = item[i]
            if m == 0:
                s = 1
                break
            continue

        item.sort(reverse=True)
        break
        
 
print(sum(item))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
lis=list(map(int,input().split()))
cost=0
for i in range (0,n):
  cost=cost+lis[i]
lis.sort()
discount=0
for i in range (0,m):
  a=0
  b=n-1
  discount=discount+lis[n-1]-lis[n-1]//2
  t=lis[n-1]//2
  for i in range (0,50):
    if lis[(a+b)//2]<t:
      a=(a+b)//2
    elif lis[(a+b)//2]>t:
      b=(a+b)//2
    else:
      a=b=(a+b)//2
  while lis[a]<t and a<n:
    a=a+1
  lis.insert(a,t)
  del lis[n]
print(cost-discount)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
lis=list(map(int,input().split()))
cost=0
for i in range (0,n):
  cost=cost+lis[i]
lis.sort()
discount=0
for i in range (0,m):
  a=0
  b=n-1
  discount=discount+lis[n-1]-lis[n-1]//2
  t=lis[n-1]//2
  for i in range (0,20):
    if lis[(a+b)//2]<t:
      a=(a+b)//2
    elif lis[(a+b)//2]>t:
      b=(a+b)//2
    else:
      a=b=(a+b)//2
  while lis[a]<t and a<n:
    a=a+1
  lis.insert(a,t)
  del lis[n]
print(cost-discount)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
lis=list(map(int,input().split()))
cost=0
for i in range (0,n):
  cost=cost+lis[i]
lis.sort()
discount=0
for i in range (0,m):
  a=0
  b=n-1
  discount=discount+lis[n-1]-lis[n-1]//2
  t=lis[n-1]//2
  for i in range (0,10):
    if lis[(a+b)//2]<t:
      a=(a+b)//2
    elif lis[(a+b)//2]>t:
      b=(a+b)//2
    else:
      a=b=(a+b)//2
  while lis[a]<t and a<n:
    a=a+1
  lis.insert(a,t)
  del lis[n]
print(cost-discount)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
lis=list(map(int,input().split()))
cost=0
for i in range (0,n):
  cost=cost+lis[i]
lis.sort()
discount=0
for i in range (0,m):
  a=0
  b=n-1
  discount=discount+lis[n-1]-lis[n-1]//2
  t=lis[n-1]//2
  for i in range (0,4):
    if lis[(a+b)//2]<t:
      a=(a+b)//2
    elif lis[(a+b)//2]>t:
      b=(a+b)//2
    else:
      a=b=(a+b)//2
  while lis[a]<t and a<n:
    a=a+1
  lis.insert(a,t)
  del lis[n]
print(cost-discount)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
lis=list(map(int,input().split()))
cost=0
for i in range (0,n):
  cost=cost+lis[i]
lis.sort()
discount=0
for i in range (0,m):
  a=0
  b=n-1
  discount=discount+lis[n-1]-lis[n-1]//2
  t=lis[n-1]//2
  for i in range (0,3):
    if lis[(a+b)//2]<t:
      a=(a+b)//2
    elif lis[(a+b)//2]>t:
      b=(a+b)//2
    else:
      a=b=(a+b)//2
  while lis[a]<t and a<n:
    a=a+1
  lis.insert(a,t)
  del lis[n]
print(cost-discount)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
lis=list(map(int,input().split()))
cost=0
for i in range (0,n):
  cost=cost+lis[i]
lis.sort()
discount=0
for i in range (0,m):
  a=0
  b=n-1
  discount=discount+lis[n-1]-lis[n-1]//2
  t=lis[n-1]//2
  for i in range (0,7):
    if lis[(a+b)//2]<t:
      a=(a+b)//2
    elif lis[(a+b)//2]>t:
      b=(a+b)//2
    else:
      a=b=(a+b)//2
  while lis[a]<t and a<n:
    a=a+1
  lis.insert(a,t)
  del lis[n]
print(cost-discount)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a_list = list(map(int, input().split()))
a_len = len(a_list)

a_list.sort(reverse=True)

for x in range(m):
    a_list[0] /= 2

    i = 0
    while i+1 < a_len and a_list[i] < a_list[i + 1]:
        a_list[i], a_list[i + 1] = a_list[i + 1], a_list[i]
        i += 1

print(sum([int(x // 1) for x in a_list]))

Submission status: Time Limit Exceeded

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

for i in range(m):
    num = max(alist)
    num = num >> 1

    alist.remove(max(alist))
    alist.append(num)

print(sum(alist))

Submission status: Time Limit Exceeded

Solution code:
from bisect import insort_left
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
for _ in range(M):
    m=A.pop(-1)
    insort_left(A,m//2)
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))] /= 2
  
for i in range(len(a)):
  a[i] = int(a[i])
  
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(sum([math.floor(x) for x in a_list]))

Submission status: Time Limit Exceeded

Solution code:
data = input().split()
# 商品数
syouhinNum = int(data[0])
# チケット数
ticketNum = int(data[1])

# 商品と値段(商品リスト)
syouhinLst = list(map(int,input().split()))

# チケットを使う
while ticketNum >= 1:
  # 最大価格の商品のインデックス
  saidai = syouhinLst.index(max(syouhinLst))
  # 最大価格の商品に割引チケットを一枚使う
  syouhinLst[saidai] = int(syouhinLst[saidai] / 2)
  # チケット数を一枚だけ減らす
  ticketNum -= 1

#解答
print(sum(syouhinLst))

Submission status: Time Limit Exceeded

Solution code:
data = input().split()
# 商品数
syouhinNum = int(data[0])
# チケット数
ticketNum = int(data[1])

# 商品と値段(商品リスト)
syouhinLst = list(map(int,input().split()))

# チケットを使う
while ticketNum >= 1:
  # 最大価格の商品のインデックス
  saidai = syouhinLst.index(max(syouhinLst))
  # 最大価格の商品に割引チケットを一枚使う
  syouhinLst[saidai] = int(syouhinLst[saidai] / 2)
  # チケット数を一枚だけ減らす
  ticketNum -= 1

# 合計金額
pay = 0

for i in range(syouhinNum):
  pay += syouhinLst[i]
  
#解答
print(pay)

Submission status: Time Limit Exceeded

Solution code:
data = input().split()
# 商品数
syouhinNum = int(data[0])
# チケット数
ticketNum = int(data[1])

# 商品と値段(商品リスト)
syouhinLst = list(map(int,input().split()))

# チケットを使う
while ticketNum >= 1:
  # 最大価格の商品のインデックス
  saidai = syouhinLst.index(max(syouhinLst))
  # 最大価格の商品に割引チケットを一枚使う
  syouhinLst[saidai] = int(int(syouhinLst[saidai]) / 2)
  # チケット数を一枚だけ減らす
  ticketNum = ticketNum -1

# 合計金額
pay = 0

for i in range(syouhinNum):
  pay += syouhinLst[i]
  
#解答
print(pay)

Submission status: Time Limit Exceeded

Solution code:
######## 関数 ############

def find_max(A):
    max = A[0]
    max_index = 0
    for i in range(len(A)):
        if A[i] > max:
            max_index = i
            max = A[i]
    return max_index

##### プログラム ###############

# 入力を受け取る
N, M = input().strip().split()
N, M = [int(N), int(M)]
A = input().strip().split()
A = list(map(int, A))     # 整数に変換

for i in range(M): # 各割引券1枚ずつ、一番高い品物に使っていく
    max_i = find_max(A)  # O(N)
    A[max_i] //= 2  # 割引券1枚で50% OFF

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

print(total_price)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

Submission status: Time Limit Exceeded

Solution code:
######## 関数 ############

# insertion sort : 小さいものから順に並べる
# リストの途中までソートされている場合に時間を短縮
# A[0], ..., A[m-1]までソート済み、A[m],...,A[n]はソートされていない場合
# insertion_sort( A[m:n+1], A[0:m]) とすることで、時間短縮
def insertion_sort(unsorted, sorted = []):
    A = sorted + unsorted # リストを連結
    for i in range(len(sorted), len(A)): # i = len(sorted), len(sorted)+1, ..., len(A)-1
        for j in range(i, 0, -1): # j = i, i-1, ..., 1
            if A[j] < A[j-1]:
                temp = A[j]
                A[j] = A[j-1]
                A[j-1] = temp
    return A

##### プログラム ###############

# 入力を受け取る
N, M = input().strip().split()
N, M = [int(N), int(M)]
A = input().strip().split()
A = list(map(int, A))     # 整数に変換

# Aを安い順にソートする
A = insertion_sort(A)

for i in range(M): # 各割引券1枚ずつ、一番高い品物に使っていく
    A[N-1] //= 2   # 右端が一番高い。1枚使うと半額
    A = insertion_sort(A[N-1:N], A[0:N-1]) # 安い順に並び替え

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

print(total_price)

Submission status: Time Limit Exceeded

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

list.sort(reverse = True)

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

result = 0
for j in range(N):
    result += list[j]

print(result)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
ans=0
while M!=0:
  val=max(A)
  index=A.index(val)
  A[index]//=2
  M-=1
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
data = input().split()
# 商品数
syouhinNum = int(data[0])
# チケット数
ticketNum = int(data[1])

# 商品と値段(商品リスト)
syouhinLstOR = input().split()
syouhinLst = []

for i in range(syouhinNum):
  syouhinLst.append(int(syouhinLstOR[i]))

# チケットを使う
while ticketNum >= 1:
  # 最大価格の商品のインデックス
  saidai = syouhinLst.index(max(syouhinLst))
  # 最大価格の商品に割引チケットを一枚使う
  syouhinLst[saidai] = int(int(syouhinLst[saidai]) / 2)
  # チケット数を一枚だけ減らす
  ticketNum = ticketNum -1

# 合計金額
pay = 0

for i in range(syouhinNum):
  pay += syouhinLst[i]
  
#解答
print(pay)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = np.array(input().split(' '), dtype='i')
        # for _ in range(num_coupon):
        #     prices[prices.argmax()] //= 2
    [np.put(prices, prices.argmax(), prices.max()//2) for _ in range(num_coupon)]
    print(prices.sum())

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = np.array(input().split(' '), dtype=np.uint32)
    for _ in range(num_coupon):
        prices[prices.argmax()] //= 2
    print(prices.sum())

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = np.array(input().split(' '), dtype=np.int64)
    for _ in range(num_coupon):
        prices[prices.argmax()] //= 2
    print(prices.sum())

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    prices = np.array(input().split(' '), dtype='i')
    for _ in range(num_coupon):
        prices[prices.argmax()] //= 2
    print(prices.sum())

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    princes = np.array(input().split(' '), dtype='i')
    for _ in range(num_coupon):
        princes[princes.argmax()] //= 2
        if princes.max() <= 0:
            break
    print(princes.sum())

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

def receive_shopping_plan():
    num_commodity, num_coupon = input().split(' ')
    num_commodity, num_coupon = int(num_commodity), int(num_coupon)
    return num_commodity, num_coupon

def calc_minimized_sum(num_commodity, num_coupon):
    princes = np.array(input().split(' '), dtype='i')
    for i in range(num_coupon):
        princes[princes.argmax()] //= 2
    print(princes.sum())

if __name__ == '__main__':
    num_commodity, num_coupon = receive_shopping_plan()
    calc_minimized_sum(num_commodity, num_coupon)

Submission status: Time Limit Exceeded

Solution code:
import heapq

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

def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]

for i in range(m):
    m -= 0
    a = heapsort(a)
    a[-1] = a[-1] // 2

print(sum(a))

"""
for i in range(m):
    a.sort()
    a.reverse()
    m -= 1
    a[0] = a[0] // 2

print(sum(a))
"""

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
INPUT = [int(i) for i in input().split(" ")]
N = INPUT[0]
M = INPUT[1]

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

#print(A)
for i in range(M):
    max = np.argmax(A)
    A[max] = A[max] // 2
    if(sum(A) == 0):
        break

#print(A)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N, M = map(int, input().split())
prices = [int(i) for i in input().split()]

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

total=0
for i in range(N):
  total += int(prices[i])
print(total)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
INPUT = [int(i) for i in input().split(" ")]
N = INPUT[0]
M = INPUT[1]

A = [int(i) for i in input().split(" ")]
#print(A)
for i in range(M):
    max = np.argmax(A)
    A[max] = A[max] // 2

#print(A)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

# 入力の取得(1行目。数値)
i = list(map(int, input().split()))

# 変数セット
# 1.購入する品物の数
itemCount = i[0]
# 2.割引券の数
discountTicketsCount = i[1]

# 入力の取得(2行目。数値)
priceList = list(map(int, input().split()))

# 割引件数分ループ
for i in  range(discountTicketsCount):

    # 全アイテムに対して、割引券を使った場合の試算を行う
    discountPrice = 0
    shouldUseItem = 0
    for idx , price in enumerate(priceList):

        # 割引券使用による割引金額を取得
        workDiscountPrice = math.ceil(price - (price / 2))

        # 最も割引金額が多い場合、候補として変数に格納
        if workDiscountPrice > discountPrice:
            discountPrice = workDiscountPrice
            shouldUseItem = idx

    # 割引金額が最大の品物に割引券を使用
    priceList[shouldUseItem] -= discountPrice

# 合計金額を出力
print(sum(priceList))

Submission status: Time Limit Exceeded

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

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

sum = 0
for x in range(len(A)):
	sum += int(A[x])

print(sum)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
A = []
for X in input().split():
	x = int(X)
	A.append(x)

for x in range(M):
	max = 0
	for y in range(N-1):
		if(A[max] < A[y+1]):
			max = y+1
	A[max] = A[max] / 2

sum = 0
for x in range(len(A)):
	sum += int(A[x])

print(sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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


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

npA = np.array([])
for x in a:
    npA=np.append(npA, x)

# for x in range(N):
#     print(a[x])
for x in range(M):
    a[np.argmax(a)] //= 2

total = 0
for x in range(N):
    total+=a[x]

print(total)

Submission status: Time Limit Exceeded

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

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

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

total = 0
for x in range(N):
    total+=a[x]

print(total)

Submission status: Time Limit Exceeded

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

a=list(map(int, input().split()))
use=list(range(N))
# for x in range(N):
#     print(l[x])

for x in range(M):
    use[a.index(max(a))]+=1
    a[a.index(max(a))] //= 2

total = 0
for x in range(N):
    total+=a[x]

print(total)

Submission status: Time Limit Exceeded

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

a.sort()

for _ in range(0, M):
    a[N-1] = a[N-1] // 2
    a.sort()

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-

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:
from bisect import bisect_right

n,m=map(int,input().split())
lis=list(map(int,input().split()))
lists=sorted(lis)

cnt=0
while cnt<m:
    y=lists[-1]//2
    del lists[-1]
    
    indexes=bisect_right(lists,y)
    #indexesというところに新しいyの値を代入しておきたい
    lists.insert(indexes,y)

    cnt+=1
print(sum(lists))

Submission status: Time Limit Exceeded

Solution code:
X = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(X[1]):
  A[A.index(max(A))] = int(max(A)/2)
sum = 0
for a in A:
  sum+=a
print(sum)

Submission status: Time Limit Exceeded

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

A = Aorg

#A.sort(reverse=True)
sumA = sum(A)

for m in range(M):
  #print(A.index(max(A)))
  sumA = int(sumA - max(A)/2)
  A[A.index(max(A))] = int(A[A.index(max(A))] - max(A)/2)
  
  """
  #print(int(A[0]/2))
  A[0] = int(A[0]/2)
  if N>1:
    if A[0]<A[1]:
      A.sort(reverse=True)
  """
print(sum(A))

Submission status: Time Limit Exceeded

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

A = Aorg

A.sort(reverse=True)

for m in range(M):
  #print(int(A[0]/2))
  A[0] = int(A[0]/2)
  if N>1:
    if A[0]<A[1]:
      A.sort(reverse=True)

print(sum(A))

Submission status: Time Limit Exceeded

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

A = Aorg

A.sort(reverse=True)

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

price = [int(x) for x in input().split(' ')]
  
for m in range(M):
  index = np.argmax(price)
  price[index] = price[index]/2.

price = [int(x) for x in price]
print(sum(price))

Submission status: Time Limit Exceeded

Solution code:
import math

n,m = map(int,input().split())
while True:
    try:
        listA=list(map(int,input().split()))
    except:
        break;
sum=0

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


for i in range(n):
  sum+=listA[i]

print(sum)

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))] = 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.sort()

for _ in range(M):
	a = A.pop()
	a = a >> 1
	for i in range(len(A)):
		if A[i] > a:
			A.insert(i, a)
			break
	else:
		A.append(a)
			

sum = 0
for a in A: sum += a
print(sum)

Submission status: Time Limit Exceeded

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

for _ in range(M):
	a = A.pop()
	a //= 2
	for i in range(len(A)):
		if A[i] > a:
			A.insert(i, a)
			break
	else:
		A.append(a)
			

sum = 0
for a in A: sum += a
print(sum)

Submission status: Time Limit Exceeded

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

for _ in range(M):
	idx = A.index(max(A))
	A[idx] //= 2
sum = 0
for a in A: sum += a
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import math
def binary_search(arr, val, start, end):
    if start == end: 
        if arr[start] > val: 
            return start 
        else: 
            return start+1
  
    if start > end: 
    	return start 
  
    mid = (start+end)//2
    if arr[mid] < val: 
        return binary_search(arr, val, mid+1, end) 
    elif arr[mid] > val: 
        return binary_search(arr, val, start, mid-1) 
    else: 
        return mid 
n,m=[int(x) for x in input().split()]
s,v=0,[]
for x in input().split():
	x=int(x)
	s+=x
	v.append(x)
v.sort()
while (m>0):
	if (v[-1]==0):
		break
	k=v[-1]/2
	s-=math.ceil(k)
	del v[-1]
	l=binary_search(v, math.floor(k), 0, len(v)-1)
	v=v[:l]+[math.floor(k)]+v[l:]
	m-=1
print(s)

Submission status: Time Limit Exceeded

Solution code:
import math
def insert(list, n): 
	j=0
	for j in range(len(list)): 
		if list[j] > n: 
			break
      
	list = list[:j] + [n] + list[j:] 
	return list
n,m=[int(x) for x in input().split()]
s,v=0,[]
for x in input().split():
	x=int(x)
	s+=x
	v.append(x)
v.sort()
while (m>0):
	if (v[-1]==0):
		break
	k=v[-1]/2
	s-=math.ceil(k)
	del v[-1]
	v=insert(v,math.floor(k))
	m-=1
print(s)

Submission status: Time Limit Exceeded

Solution code:
# ABC141 D -Powerful Discount Tickets

import numpy

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

str_A = input().split()
int_A = [int(n) for n in str_A]

for i in range(M):
    int_A[numpy.argmax(int_A)] = numpy.max(int_A)//2

print(sum(int_A))

Submission status: Time Limit Exceeded

Solution code:
# ABC141 D -Powerful Discount Tickets

import numpy

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

str_A = input().split()
int_A = [int(n) for n in str_A]

for i in range(M):
    int_A[numpy.argmax(int_A)] = max(int_A)//2

print(sum(int_A))

Submission status: Time Limit Exceeded

Solution code:
n,m=[int(x) for x in input().split()]
v=[int(x) for x in input().split()]
def insert(list, n): 
	j=0
	for j in range(len(list)): 
		if list[j] > n: 
			break
      
	list = list[:j] + [n] + list[j:] 
	return list
v.sort()
while (m>0):
	if (v[-1]==0):
		break
	k=v[-1]/2
	del v[-1]
	v=insert(v,k)
	m-=1
i,sum=0,0
while(i<n):
	sum+=int(v[i])
	i+=1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n,m=[int(x) for x in input().split()]
v=[int(x) for x in input().split()]
def insert(list, n): 
	j=0
	for j in range(len(list)): 
		if list[j] > n: 
			break
      
	list = list[:j] + [n] + list[j:] 
	return list
v.sort()
while (m>0):
	k=v[-1]/2
	del v[-1]
	v=insert(v,k)
	m-=1
i,sum=0,0
while(i<n):
	sum+=int(v[i])
	i+=1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n,m=[int(x) for x in input().split()]
v=[int(x) for x in input().split()]
v.sort(reverse=True)
while (m>0):
	v[0]=v[0]/2
	v.sort(reverse=True)
	m-=1
i,sum=0,0
while(i<n):
	sum+=int(v[i])
	i+=1
print(sum)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8

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

for m in range(M):
    A[A.index(max(A))] = max(A)/2
total = sum(map(int, A))

print(total)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import numpy as np
N, M = input().split()
N, M = int(N), int(M)
prices = input().split()
prices = np.array([int(p) for p in prices])

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
N, M = input().split()
N, M = int(N), int(M)
prices = input().split()
prices = [int(p) for p in prices]

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