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:
import numpy as np
N,M = map(int,input().split())
A = [i for i in map(int,input().split())]
A = np.array(A).astype('float')

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

Submission status: Time Limit Exceeded

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

for i in range(M):
    A[0]=A[0]//2
    A=np.sort(A)[::-1]
print(np.sum(A))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 13 22:46:19 2019

"""

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(int(1e6))
import math

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

if N > M:
    A.sort(reverse=True)
    A1 = A[0:M]
    A2 = A[M:]
    for _ in range(M):
        i = A1.index(max(A1))
        A1[i] = A1[i] // 2
    print(sum(A1 + A2))
else:
    for _ in range(M):
        i = A.index(max(A))
        A[i] = A[i] // 2
    print(sum(A))

Submission status: Time Limit Exceeded

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

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

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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
if 14*N <= M:
    print(0)
else:
    sum = sum(A)

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

    print(sum)

Submission status: Time Limit Exceeded

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


for i in range(m):
    max_b = b[0]
    b.pop(0)
    b.append(max_b//2)
    b = sorted(b,reverse = True)
print(sum(b))

Submission status: Time Limit Exceeded

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

s = input().split()
N = int(s[0])
M = int(s[1])
A = np.array(list(map(int, input().split())))
for _ in range(M):
    A[A.argmax()] //= 2
print(np.sum(A))

Submission status: Time Limit Exceeded

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

for _ in range(M):
    As[As.argmax()] /=  2.0
As *= 2.0
ans = np.sum(np.floor(As))
print(int(ans))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split()) 
A = [int(a) for a in input().split()]
for i in range(m): 
    k = A.index(max(A))
    A[k] = A[k] // 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]=a[-1]//2
print(sum(i for i in a))

Submission status: Time Limit Exceeded

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

items = sorted(items)

for i in range(M):
    target = N-1
    items[target] = items[target] // 2
    for i in range(N):
        if items[target-1] > items[target]:
            items[target-1], items[target] = items[target], items[target-1]
            target -= 1
        else:
            break

print(sum(items))

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in range(n[1]):
    a.sort(reverse=True)
    a[0] = math.floor(a[0] / 2)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

price.sort()

if m < n:
    add = sum(price[:n-m])
    price = price[n-m:]
else:
    add = 0

while m:
    p = price.pop() >> 1
    if len(price) < m:
        price.insert(bisect.bisect(price, p), p)
    elif len(price) == 0 or price[0] >= p:
        add += p
    else:
        price.insert(bisect.bisect(price, p), p)
    m -= 1
print(sum(price)+add)

Submission status: Time Limit Exceeded

Solution code:
sn,sm = input().split(" ")
n = int(sn)
m = int(sm)
sa = input().split(" ")
l = len(sa)
a = []

for i in range(l):
  a.append(int(sa[i]))

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 sys
input=sys.stdin.readline

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

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

A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2

if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        while A[0]>=A[1] and cnt<M:
            cnt+=1
            A[0]=A[0]//2
        if cnt==M:break
        else:
            b=A[0]
            for i in range(1,N):
                if A[i]>b:A[i-1]=A[i]
                else:
                    A[i-1]=b
                    break
    
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
(_, M) = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
A.reverse()
for i in range(M):
  A[A.index(max(A[:i+1]), 0, i+1)] //= 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 dc in range(M):
        A[-1] = A[-1]//2
        i = 1
        while i < N and A[-i-1] > A[-i]:
            A[-i-1],A[-i] = A[-i],A[-i-1]
            i += 1
    print(sum(A))
if __name__ == "__main__":
    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):
    a[a.index(max(a))]/=2
sm = 0
for i in range(n):
    sm+=int(a[i])
print(sm)

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.append(a.pop(a.index(max(a)))//2)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from collections import deque
import sys
input = sys.stdin.readline

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

Submission status: Time Limit Exceeded

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

n,m = map(int,input().split())
a =list(map(int,input().split()))
b = sorted(a,reverse=True)


for i in range(m):
    max_b = b[0]
    b.pop(0)
    b.append(max_b//2)
    b = sorted(b,reverse = True)
print(sum(b))

Submission status: Time Limit Exceeded

Solution code:
import copy

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

A.sort(reverse=True)

m = 0
b = 0
for i in range(M):
    tj = 0
    cnt = 0
    for j in range(N):
        if A[j] == 0:
            continue
        t = A[j] - A[j]//2
        if cnt <= t:
            cnt = t
            tj = j
    A[tj] = A[tj] // 2
    tt = sum(A)
    if b == tt:
        break
    tt = b

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
cnt = 0
while True:
    A[0] = A[0] // 2
    cnt += 1
    A = sorted(A, reverse=True)

    if cnt == M:
        break

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
N, M = map(int,input().split())
A = list(map(int,input().split()))
ans = sum(A)
A.sort()
for i in range(M):
    ans = ans - math.ceil(A[N-1]/2)
    A.append(math.floor(A[N-1]/2))
    A.remove(A[N-1])
    if A[N-1]<=A[N-2]:
        A.sort()  
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m):
    tmp_max = max(a)
    a.remove(tmp_max)
    a.append(tmp_max // 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)

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N,M = map(int,input().split())
ls1 = np.array(list(map(int,input().split())))
for i in range(M):
  ls1[ls1.argmax()] = ls1[ls1.argmax()]//2
print(ls1.sum())

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())
    A = list(map(int, input().split()))+[0]

    A.sort(reverse=True)
    tmp = 0
    for _ in range(M):
        A[0] >>= 1
        if A[0] < A[1]:
            tmp = A[0]
            for i in range(1, N+1):
                if tmp < A[i]:
                    A[i-1] = A[i]
                else:
                    A[i-1] = tmp
                    break
    print(sum(A))


if __name__ == "__main__":
    main()

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 
    
sum = 0
for i in range(n):
  A[i] = math.floor(A[i])
  sum += A[i]
print(sum)

Submission status: Time Limit Exceeded

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

for i in range(m):
  mx = max(alst)
  idx = alst.index(mx)
  alst[idx] = alst[idx]/2.0
#print(alst)
for j in range(n):
  alst[j] = math.floor(alst[j])
#print(alst)

print(sum(alst))

Submission status: Time Limit Exceeded

Solution code:
def binary_search(alist, item):
    low = 0                        # lowとhighを使ってリストの検索部分を追跡
    high = len(alist) - 1
    while low <= high:             # 1つの要素に絞り込まれるまでの間は...
        mid = (low + high) // 2
        guess = alist[mid]          # 真ん中の要素を調べる
        if guess == item:          # アイテムを検出
            return mid
        if guess > item:           # 推測した数字が大きすぎた
            high = mid - 1
        else:                      # 推測した数字が小さすぎた
            low = mid + 1
    return max(high,low)

n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
while m>0:
    
    b=a[n-1]//2
    a.pop(n-1)

    s=binary_search(a,b)
    a.insert(s,b)
    m=m-1
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
num ,m =map(int,input().split())
if num == 1:
    s = int(input())
    print(s//(2**m))
    
else:
    arr = sorted(list(map(int,input().split())),reverse=True)

    for i in range(m):
        for j in range(len(arr)-1):
            if arr[j]//2 >= arr[j+1]:
                arr[j] = arr[j] //2
                break
            else:
                arr[j] = arr[j] //2
                
                if arr[j] < arr[j+1]:
                    arr[j],arr[j+1] = arr[j+1],arr[j]
                    if len(arr) >= j+3:
                        if arr[j+1] < arr[j+2]:
                            arr = sorted(arr,reverse=True)
                break

    print(sum(arr))

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]/=2
print(sum(list(map(int,a))))

Submission status: Time Limit Exceeded

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

import math

def waribiki(price):
  return math.floor(price/2)


n, m = map(int, input().split(" "))
a = input().split(" ")
a_i = [int(s) for s in a]
for i in range(0, m):
  max_index = a_i.index(max(a_i))
  a_i[max_index] = waribiki(max(a_i))

print(sum(a_i))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

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:
import copy
import math
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
total=0  
for i in range(n):
  total+=math.floor(a[i])
print (total)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
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==250:
        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 = list(map(int, input().split()))
heapq.heapify(a)

for _ in range(m):
    maximum = a.index(max(a))
    a[maximum] = a[maximum] // 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):
    temp = A.index((max(A)))
    tempM = M
    while temp == A.index((max(A))):
        if tempM > M:
            break
        A[A.index((max(A)))] //= 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()))
            
a = sorted(a, reverse = True)

for i in range(m):
  a[0] = a[0] // 2
  a = sorted(a, reverse = True)
 # print(a)
  
sum = 0
for i in range(n):
  sum = sum + int(a[i])
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import sys
import heapq

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

input = sys.stdin.readline
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
A = heapsort(A)

for _ in range(M):
    A[N-1] //= 2
    A = heapsort(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())))

B = A.copy()
discount_cnt = np.zeros(N)

for i in range(M):
    tmp = B / 2
    tmp_idx = np.argmax(tmp)
    discount_cnt[tmp_idx] += 1
    B[tmp_idx] = tmp[tmp_idx]

tmp_arr = np.array([2 ** i for i in discount_cnt])
print(int(np.sum(np.floor(A / tmp_arr))))

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):
    # idx = A.index(max(A))
    # A[idx] //= 2
    idx = A.index(max(A[:i+1]))
    A[idx] //= 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.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 = sorted(list(map(int,input().split())),reverse=True)
for i in range(m):
    b = a.pop(a.index(max(a))) // 2
    a.append(b)
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,reverse=True)
for i in range(m):
    j=a.index(max(a))
    a[j]=int(a[j]/2)
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
'use strict'
import math
N, M = map(int, input().split())
goods_price_list = list(map(int, input().split()))

for i in range(M):
  max_index = goods_price_list.index(max(goods_price_list))
  goods_price_list[max_index] = math.floor(goods_price_list[max_index]/2)

print(sum(goods_price_list))

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):
    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=[int(i) for i in input().split()]
while m>0:
    b=max(a)
    a.remove(b)
    a.append(b//2)
    m-=1
print(sum(a))

Submission status: Time Limit Exceeded

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

from collections import deque
queue=deque(A)
for i in range(M):
    queue.extend([max(queue)//2])
    queue.remove(max(queue))
print(sum(queue))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
L1 = input().split(" ")
L2 = input().split(" ")
tickets = int(L1[1])
L2int = [int(s) for s in L2]

for t in range(tickets):
    M = max(L2int)
    L2int[L2int.index(M)] = M//2
print(sum(L2int))

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):
    b = a[-1] //2
    c = a.pop(-1)
    a.append(b)
    a.sort()
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)
            #print(la)
            for j in range(i, n-1):
                if la[j] <= la[j+1]:
                    tmp = la[j]
                    la[j] = la[j+1]
                    la[j+1] = tmp
                else:
                    break
            break
        else:
            la[i] = la[i] // 2
            d = 1
            break
    #la.sort(reverse=True)
    #print(la)
    # sprint(d)
    m -= d

print(sum(la))

Submission status: Time Limit Exceeded

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

for i in range(M):
  m = max(A)
  if m == 0:
    break
  A.remove(m)
  A.append(int((m - m % 2) * 0.5))
S = 0
for j in range(N):
  S += A[j]
print(S)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

#input = raw_input
N, M = map(int, input().split(" "))
prices = sorted(map(int, input().split(" ")), reverse=True)


count = 0
cur_prices = []
for i in range(M):
    if i <= N-1:
        cur_prices = cur_prices + [prices[i]]

    max_i = np.argmax(cur_prices)
    cur_prices[max_i] /= 2 
    count += 1

out = int(np.floor(cur_prices).sum()) + sum(prices[i+1:])
print(out)

Submission status: Time Limit Exceeded

Solution code:
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
for _ in range(M):
    a = int(max(A))
    b = A.index(a)
    A[b] = math.floor(a//2)
c = sum(A)
print(c)

Submission status: Time Limit Exceeded

Solution code:
import copy
import math
def xx(x,y):
    return math.log(x) - y*math.log(2)
def yy(x, y):
    return int(x/(2**y))
N,M = map(int, input().split())
A = list(map(int, input().split()))
AA = list()
for a in A:
    AA.append(math.log(a))
ti = list()
for n in range(N):
    ti.append(int(0))

for m in range(M):
    max = -1
    maxn = -1
    for n in range(N):
        if max < AA[n]:
            max = AA[n]
            maxn = n
    ti[maxn] += 1
    AA[maxn] = xx(A[maxn], ti[maxn])

s = 0
for i in range(N):
    if not(ti[i] == 0):
        A[i] = yy(A[i], ti[i])
for a in A:
    s += a

print(s)

Submission status: Time Limit Exceeded

Solution code:
import sys
from collections import Counter
import bisect
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

N, M = MAP()
A = LIST()
A.sort()

for i in range(M):
    if A[N-1] < A[N-2]:
        a = A[N-1]
        A.pop(N-1)
        bisect.insort_right(A,a)

    A[N-1] //=2


print(sum(A))

Submission status: Time Limit Exceeded

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

A=list(map(int, input().split()))
A=np.array(A)
for i in range(M):
	A[np.argmax(A)]/=2
np.floor(A)
SUM=np.sum(A)
print(SUM)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N,M=input().split(" ")
N=int(N)
M=int(M)
Alist=input().split(" ")
Alist = [float(A) for A in Alist]


for m in range(M):
    i=Alist.index(max(Alist))
    Alist[i]=Alist[i]/2
    if Alist[i]==0:
        break
    # print(Alist)


Alist_i = [int(A) for A in Alist]

print(sum(Alist_i))

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):
    lst[lst.index(max(lst))] = max(lst) // 2 

print (sum(lst))

Submission status: Time Limit Exceeded

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

while M != 0:
    max_ind = A.index(max(A))
    A[max_ind] = int(max(A)/2)
    M -= 1
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import copy

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

A.sort(reverse=True)

m = 0
for i in range(M):
    tj = 0
    cnt = 0
    for j in range(N):
        if A[j] == 0:
            continue
        t = A[j] - A[j]//2
        if cnt <= t:
            cnt = t
            tj = j
    A[tj] = A[tj] // 2

print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect
import math

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

for m in range(M):
    A[N-1] = math.floor( A[N-1]/2 )
    temp = A[N-1]
    del A[N-1]
    # 挿入    
    bisect.insort(A, temp)
print(sum(A))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
#-------------------------------------------------------------------
import sys
def p(*_a):
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
#-------------------------------------------------------------------
from bisect import bisect_right as br
from bisect import bisect_left  as bl
from bisect import insort_right as ir
from bisect import insort_left  as il
#-------------------------------------------------------------------

N, M = map(int, input().split())		# 5 7 2
A = sorted(list( map(int, input().split()) ))

p("A ",A)

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


while M>0:
	a = A.pop(-1)
	if int(a)==1: break

	a/=2
	M-=1
	
	b = A[-1]
	while a >= b:
		a/=2
		M-=1
		
	ir(A,a)
	
	p("a,b,A ",a,b,A)

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
AA = [0 for i in range(N)]
y = [0 for i in range(N)]

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

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

for i in range(m):
    obj = a.pop()
    x = obj/2
    insert_index = bisect.bisect_left(a,x)
    a.insert(insert_index,x)
    
ans = 0
for i in range(n):
    price =  math.floor(a[i])
    ans += int(price)
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import bisect
N, M = list(map(int, input().split(' ')))
As = list(map(int, input().split(' ')))
#  sortしていちばん大きいのをとって半額にしてAsに戻してもう一回ソートするのをM回やれば1e5 にN log N +alpha
As = sorted(As)
while M:
    hoge = As.pop(-1) // 2
    M -= 1
    while M and As and hoge >= As[-1]:
        hoge = hoge // 2
        M -= 1
    bisect.insort(As, hoge)
print(sum(As))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math
N,M = [int(x) for x in input().split(" ")]
a = [int(x) for x in input().split(" ")]
Ms = [0 for _ in range(N)]
alog = np.log2(a)
for _ in range(M):
    idx = np.argmax(alog)
    Ms[idx] += 1
    alog[idx] -= 1
res = 0
for i, price in enumerate(a):
    res += math.floor(price / (2 ** Ms[i]))
print(res)

Submission status: Time Limit Exceeded

Solution code:
from numpy import array, sum, argmax

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

for i in range(M):
  #print(A)
  idx = argmax(A)
  A[idx] >>= 1

print(sum(A))

Submission status: Time Limit Exceeded

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

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 m in range(M):
  if len(a)>1:
    max_=max(a[:2])
    a.remove(max_)
    flag=1
    for n in range(N-1):
      if max_//2<a[n]:
        pass
      else:
        a.insert(n,max_//2)
        flag=0
        break
    if flag:
      a.append(max_//2)
  else:
    a[0]=a[0]//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 range(m):
    x=a[-(i+1)]//2
    bisect.insort(a,x)
print(sum(a[:n]))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

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

print(np.sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, M = map(int, input().split())
A = list(map(int,input().split()))
A = np.array(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):
    aa = A.argmax()
    A[aa] = A[aa]//2
  print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
while m > 0:
    M = max(a)
    tmp = a.index(M)
    a[tmp] = a[tmp] // 2
    m -= 1
print(sum(a))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# Y 割引券の枚数
# 割引 = x / 2 ** Y
import math

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

sum = list()

for i in range(M):
    prices = master_prices
    prices[prices.index(max(prices))] = prices[prices.index(max(prices))] / 2
    # print(prices[i])
    # prices[i] / 2 ** Y

total = 0
for i in prices:
    total += math.floor(i)

print(total)

Submission status: Time Limit Exceeded

Solution code:
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
cnt = 0
while True:
    A[0] = A[0] // 2
    cnt += 1
    A = sorted(A, reverse=True)
    
    if cnt == M:
        break

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

n, m = map(int, input().split())
a = list(map(int, input().split()))
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]
  li0 = li.pop(0)
  d[b] = li
  a[li0] = b/2
  if b/2 in d:
    l = d[b/2]
    l.append(li0)
    d[b/2] = l
  else:
    d[b/2] = [li0]

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

Submission status: Time Limit Exceeded

Solution code:
import heapq
n,m=map(int,input().split())
item=list(map(int,input().split()))
for i in range(n):item[i]=item[i]*-1
for i in range(m):
    heapq.heapify(item)
    a=heapq.heappop(item)
    heapq.heappush(item,((-1*a)//2)*-1)

print(sum(item)*-1)

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)) and price.count(highest) == 1:
            use = 1
            discount = math.floor(price[highest_index] / (2 ** use))
            if discount < highest:
                price[highest_index] = discount
                tickets -= use
            else:
                use+=1
    else:
        discount = math.floor(price[highest_index] / (2 ** tickets))
        tickets = 0
        price[0] = discount
print(sum(price))