Problem:


Score : 400 points

Problem Statement

Takahashi is going to buy N items one by one.

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

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

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

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

Constraints

All values in input are integers.

1 \leq N, M \leq 10^5

1 \leq A_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N M
A_1 A_2 ... A_N

Output

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

Sample Input 1

3 3
2 13 8

Sample Output 1

9

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

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

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

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

Sample Input 2

4 4
1 9 3 5

Sample Output 2

6

Sample Input 3

1 100000
1000000000

Sample Output 3

0

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

Sample Input 4

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

Sample Output 4

9500000000



Sample input:
3 3
2 13 8


Sample output:
9

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def main():
    import bisect
    N, M = (int(i) for i in input().split())
    A = [int(i) for i in input().split()]
    A.sort()
    for divcnt in range(M):
        tmp = (A.pop())//2
        for i in range(1,min(101,N)):
            if A[-i] < tmp:
                A.insert(-i+1,tmp)
                break
        else:
            bisect.insort(A,tmp)
    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))]=((max(A))//2)
 
print(sum(A))

Submission status: Time Limit Exceeded

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


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = map(int, input().split())
a_array = list(map(int, input().split()))
a_array.sort(reverse=True)
skip_count = 0
## for x in range(n):
for x in range(m):
    ## 回数券分ループ
    for y in range(skip_count, n):
        ## 品物数分ループ
        if y + 1 == n or a_array[y] >= max(a_array[y + 1: n]):
            ## index(y + 回数券使った回数)より大きければ半額しても良い
            a_array[y] = math.floor(a_array[y] / 2)
            if y + m < n and a_array[y] <= a_array[y + m]:
                skip_count += 1
            break
print(int(sum(a_array)))

Submission status: Time Limit Exceeded

Solution code:
import math

N, M = map(int, input().split(" "))
Prices = list(map(int, input().split(" "))) + [0] # 門番

Prices.sort(reverse=True)

HighPriceIdx = 0
while M > 0:
    price_1st = Prices[HighPriceIdx]
    price_2nd = Prices[HighPriceIdx+1]

    if price_1st == 0:
        break

    # discount
    while price_1st > price_2nd:
        price_1st = price_1st // 2
        M = M - 1

    Prices[HighPriceIdx] = price_2nd
    Prices[HighPriceIdx+1] = price_1st
    Prices.sort(reverse=True)


print(sum(Prices))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
#a = list(reversed(sorted(a)))
ans = 0
#minV = 10**15
total = sum(a)
#print(total)

while True:
    if m <= 0:
        break
    maxV = max(a)
    idx = a.index(maxV)
#    total = total - maxV + (maxV // 2)
    a[idx] = a[idx] // 2

#    a[0] = a[0] // 2
#    a = list(reversed(sorted(a)))
    m -= 1

ans = sum(a)
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 _ in range(M):
  max_a = np.max(A)
  idx = np.where(A==max_a)
  A[idx[0][0]] = max_a/2
print(np.sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
import sys

def main():
  input = sys.stdin.readline
  N,M = map(int,input().split())
  a_l = list(map(int,input().split()))
  a_l.sort()

  for _ in range(M):
    discount = a_l[-1]//2
    a_l.pop()
    bisect.insort(a_l,discount)

  print(sum(a_l))

if __name__ == "__main__":
  main()

Submission status: Time Limit Exceeded

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

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

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

result = 0
for i in A:
    result += int(i)

print(result)

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):
        a.sort(reverse=True)

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
for i in range(M):
  A[-1] = A[-1]/2
  if len(A) == 1:
    continue
  elif A[-1] < A[-2]:    
    A = sorted(A)
A = np.array(A)
A = np.floor(A)
print(int(np.sum(A)))

Submission status: Time Limit Exceeded

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

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

ans = sum(A)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
if len(a) == 1:
    ans = a[0] * (0.5) ** m
    print(int(ans))
    exit()
while m > 0:
    a.sort(reverse=True)
    #print(m)
    plus = a[0] - a[0]//2
    ngtv = a[1] - a[1]//2
    if plus > ngtv:
        m -= 1
        a[0] = a[0]//2
    else:
        m -= 1
        a[1] = a[1]//2
    #print(a)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math

n, m = map(int, input().split())
A = list(map(int, input().split()))
As = sorted(A, reverse = True)
aas = As[0:m]
bs = As[m:]
for i in range(m):
    ii = math.floor(aas[0]/2)
    aas[0] = ii
    if len(aas) > 1:
        if aas[0] < aas[1]:
            aas = sorted(aas, reverse=True)


print(int(sum(aas)+sum(bs)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
num_pdt, num_coup = map(int, input().split())
price_pdt =  list(map(int, input().split()))

for i in range(num_coup):
  price_pdt[price_pdt.index(max(price_pdt))] = int(price_pdt[price_pdt.index(max(price_pdt))]/2)

print(sum(price_pdt))

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(np.sum(ls1))

Submission status: Time Limit Exceeded

Solution code:
n,m  =map(int,input().split())
a = [int(i) for i in input().split()]
a.sort()
ans = 0

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

Submission status: Time Limit Exceeded

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

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

for i in range(M):
    A.extend([max(A)//2])
    A.remove(max(A))
print(sum(A))

Submission status: Time Limit Exceeded

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

for _ in range(m):
    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())

# print(N)
# print(M)

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

A = sorted(A, reverse=True)
# print(A)

for i in range(M):
    # print(i)
    A[0] = int(A[0] / 2)
    A = sorted(A, reverse=True)
    
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):
    max = 0
    for j in range(n):
        if max < a[j]:
            max = a[j]
            max_i = j
    a[max_i] = math.floor(a[max_i] / 2)
###    a[a.index(max(a))] = math.floor(a[a.index(max(a))] / 2)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a=  list(map(int,input().split()))
for i in range(m):
    a[a.index(max(a))]=a[a.index(max(a))] //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()))
i = M
if (len(A) > 1):
    while (i > 0):
        list.sort(A, reverse=True)
        times = A[0] / A[1]
        log = math.floor(math.log(times, 2)) + 1
        A[0] = A[0] // 2 ** log
        i -= log
else:
    A[0] = A[0] // (2 ** M)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
#n₌品物の数
#m=割引券の数
#ans =合計金額

n,m = map(int, input().split())
ans =0
#割引券をY枚使うと、品物をX/2**Y円で変える()小数点はむし
ma =0
#各品物の値段を保管しておくための配列
a = list(map(int, input().split()))

#品物を高いもの順に並び替える
a.sort(reverse=True)

#割引をｍ回繰り返す
for i in range(m):
    ma =a[0]
    ma = int(ma/2)
    a[0] = ma
    if(ma == 0):
        break
    a.sort(reverse =True)
    
ans = int(sum(a))
print(ans)

Submission status: Time Limit Exceeded

Solution code:
one = input()
two = input()

#one = '4 4'
#two = '1 9 3 5'

N, M = map(int, one.split())
Ar = map(int, two.split())
Ar = sorted(Ar , reverse=True)

for i in range(M):
    Ar[0] = Ar[0] / 2
    Ar = sorted(Ar , reverse=True)

Ar = map(int, Ar)
print(sum(Ar))

Submission status: Time Limit Exceeded

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

from sys import stdin
import math

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

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

A_list.sort(reverse=True)

for i in range(M):
    A_list[0] =  A_list[0] // 2
    if len(A_list) == 1:
        continue
    if A_list[0] < A_list[1]:
        A_list.sort(reverse=True)


print(sum(A_list))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n, m = list(map(int, input().split()))
A = np.array(list(map(int, input().split())) + [0])
count = 0
while(count < m):
    idxs = np.argsort(A)
    y = min(m - count, max(np.floor(np.log2(A[idxs[-1]] / (A[idxs[-2]] + 1e-9))), 1))
    A[idxs[-1]] = A[idxs[-1]] // 2.0**y
    count += 1 * y
print(A.sum())

Submission status: Time Limit Exceeded

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

N, M = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)

for m in range(M):
    a[0] = a[0] // 2
    for i in range(N-1):
        if a[i] < a[i+1]:
            tmp = a[i]
            a[i] = a[i+1]
            a[i+1] = tmp
        else:
            break
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
for t in range(m):
	b = a[0]//2
	del a[0]
	if len(a) == 0:
		a.append(b)
	elif b <= a[-1]:
		a.append(b)
	else:
		for s in range(n-1):
			if b >= a[s]:
				a.insert(s, b)
				break
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math


def max_index(list, max_index):
    r = -1
    max = -1
    for i in range(max_index + 1):
        v = list[i]
        if v > max:
            max = v
            r = i
    return r


def use_coupon(a, m):
    current_index = 0
    for _ in range(m):
        index = max_index(a, current_index)
        a[index] /= 2
        current_index += index + 1
        if current_index >= len(a):
            current_index = len(a)-1


def sum(a):
    s = 0
    for v in a:
        s += math.floor(v)
    return s


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

use_coupon(a, m)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import collections as c
ip = lambda : map(int, input().split())
# ##############
N,M = ip()
A = list(ip())
am = {}
for i in A:
    am[i] = am.get(i,0) + 1

while M>0:
    ix = max(am.keys())
    if am[ix] <= M:
        M -= am[ix]
        am[ix//2] = am.get(ix//2,0) + am[ix]
        if ix!=0: am.pop(ix)
        else: break
    else :
        am[ix//2] = am.get(ix//2,0) + M
        am[ix] -= M
        break

ans = 0
for i,j in am.items():
    ans += i*j
print(ans)

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:

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

a.sort()

for i in range(n[1]):
    tmp = a.index(max(a))
    a[tmp] /= 2
    #a.sort()
    #max(a) /= 2

b = list(map(int, a))
print(sum(b))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

Submission status: Time Limit Exceeded

Solution code:
# D - Powerful Discount Tickets

def power(price, ticket_count):
    return int(price // (2 ** ticket_count))

# n: 商品数
# m: チケットの枚数
n, m = map(int, input().split())
data = list(map(int, input().split()))

ans = 0

for i in range(m):
    data.sort()
    data = data[::-1]

    max_data = data[0]
    if max_data == 0:
        break

    max_point = 0
    data[max_point] = power(data[max_point], 1)

print(sum(data))

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

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

Submission status: Time Limit Exceeded

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

A=list(map(int,input().split()))
A.sort()
for w in range(M):
    A[N-1]=A[N-1]/2
    #max=A[N-1]
    
    if A[N-1]<A[N-2]:
        #A[N-1]=A[N-2]
        #A[N-2]=max
        A.sort()
    #print(A)

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

Submission status: Time Limit Exceeded

Solution code:
str = input()

split = str.split(" ")

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

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

split = input().split(" ")
for i in range(N):
  HowMuch[i] = int(split[i])

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0 for _ in range(M+1)] for j in range(N+1)]
B = [[A[i]//2**k for k in range(M+1)] for i in range(N)]
for i in range(0, N):
  for j in range(0, M+1):
    dp[i+1][j] = min([dp[i][j-k] + B[i][k] for k in range(0, M+1) if j-k>=0])
print(dp[N][M])

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
p = sorted(list(map(int, input().split())))
for i in range(m):
    p.append(p.pop(-1)//2)
    p.sort()
print(sum(p))

Submission status: Time Limit Exceeded

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

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

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 


print(np.sum(a))

Submission status: Time Limit Exceeded

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

for _ in range(M):
  A.sort()
  A[-1]//=2

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(m):
    a.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=[int(i) for i in input().split()]

ans=sum(a)

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
Am = list(map(int, input().split()))
A = sorted(Am, reverse=True)
A.append(0)
for m in range(M):
    a = int(A[0] / 2)
    n = 0
    while A[n + 1] > a and n < N - 1:
        n += 1
    del A[0]
    A.insert(n,a)
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]
 
get2.sort()
 
for i in range(M):
 
  get2[N -1] = get2[N -1] // 2
  get2.sort()
  
print(sum(get2))

Submission status: Time Limit Exceeded

Solution code:
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
total = 0
while A[N-1] >= A[N-2]:
    A[N-1] //= 2
    M -= 1
    A.sort()
    if M <= 0:
        break
for i in range(N):
    total += A[i]
print(total)

Submission status: Time Limit Exceeded

Solution code:
import math

def main():
    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(' ')]
    A.sort()
    for i in range(0, M):
        flag = A.index(max(A))
        A[flag] = A[flag]/2
        
    for i in range(0, N):
        A[i] = math.floor(A[i])
    print(sum(A))

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(m):
    max = 0
    for j in range(n):
        if a[j] > max:
            max = a[j]
            maxIndex = j
    a[maxIndex] /= 2

count = 0
for i in range(n):
    count += math.floor(a[i])

print(count)

Submission status: Time Limit Exceeded

Solution code:
from functools import reduce
from operator import add

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

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

print(reduce(add, alist))

Submission status: Time Limit Exceeded

Solution code:
D = input().split(' ')
N = int(D[0])
M = int(D[1])
D2 = input().split(' ')

A = []
for i in D2:
  A.append(int(i))

A.sort(reverse=True)

used = 0
n = 0

while True:
  A[0] = int(A[0] / 2)
  k = 0
  for k in range(N - 1):
    if A[k] < A[k + 1]:
      tmp = A[k]
      A[k] = A[k + 1]
      A[k + 1] = tmp
    else:
      break
      
  used = used + 1
  if used == M:
    break

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

Submission status: Time Limit Exceeded

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

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

B = [0]*N
C = [0]*N

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

result = 0
for i in A:
    result += int(i)

print(result)

Submission status: Time Limit Exceeded

Solution code:
import math
n_m_str = input()
n_m = n_m_str.split(" ")
N = int(n_m[0])
M = int(n_m[1])

a_str = input()
a_s = a_str.split(" ")
a_list = []
for a in a_s:
    a_list.append(int(a))
for i in range(M):
    index = a_list.index(max(a_list))
    a_list[index] /= 2
sum = 0
for i in a_list:
    sum += math.floor(i)
print(sum)

Submission status: Time Limit Exceeded

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

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)
trimeed = len(As) - 1
for i in range(M):
    hoge = As[-1] // 2
    As = As[:-1]
    t=bisect.insort(As, hoge)
print(sum(As))

Submission status: Time Limit Exceeded

Solution code:
#D
n, m = map(int,input().split())
a = list(map(int,input().split()))
i = 0
a.sort(reverse=True)
if n == 1:
    a[0] = a[0]//(2**m)
else:
    while i < m:
        tmp = a[0]
        if a[0] == 0:
            break
        second = a[1]
        p = min(m - i, max(1, (tmp / second) **.5//1))
        a[0]=(tmp//(2**p))
        a.sort(reverse=True)
        i += p
print(sum(a))

Submission status: Time Limit Exceeded

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


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)


for _ in range(M):
    val_list[0] = val_list[0] // 2
    i = 0
    while i < N - 1 and val_list[i] < val_list[i + 1]:
        tmp = val_list[i]
        val_list[i] = val_list[i + 1]
        val_list[i + 1] = tmp
        i += 1

print(sum(val_list))

Submission status: Time Limit Exceeded

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

for _ in range(m):
    maximum = max(zip(a, range(len(a))))[1]
    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()))
# A.sort(reverse=True)
for i in range(M):
    a = A.index(max(A))
    A[a] = A[a]//2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
num_pdt, num_coup = map(int, input().split())
price_pdt =  list(map(int, input().split()))

for i in range(num_coup):
  price_pdt[price_pdt.index(max(price_pdt))] /= 2

price_pdt_int = [int(i) for i in price_pdt]
print(sum(price_pdt_int))

Submission status: Time Limit Exceeded

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

for i in range(M):
  A[A.argmax()] = np.max(A)//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 = sorted(_a)

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

print(np.sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
def PowerfulDiscountTickets():
	N, M = map(int, input().split())
	A = list(map(int, input().split()))
	for _ in range(M):
		A.sort(reverse=True)
		A[0] = math.floor(A[0]/2)
	# print(N, M, A)
	print(sum(A))
	
PowerfulDiscountTickets()

Submission status: Time Limit Exceeded

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

def main():
    _,M=map(int,input().split())
    A = list(map(int, input().split()))
    A.sort()
    while M>0:
        a = A.pop()
        if a == 0:
            print(0)
            return
        if A:
            b = A.pop()
            while a >= b:
                a //= 2
                M -= 1
            bisect.insort(A, b)
        else:
            a //= 2**M
            M = 0
        bisect.insort(A, a)
    print(sum(A))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def discountPrice(X, Y):
    return X - int(X / 2**Y)

for i in range(K) :
    maxDiscountPrice = 0
    target = 0
    for index,a in enumerate(A) :
        d = discountPrice(a,1)
        if maxDiscountPrice < d :
            maxDiscountPrice = d
            target = index

    A[target] -= maxDiscountPrice

print(sum(A))

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]
sumi=0
for i in range(N):
    sumi+=A[i]
print(sumi)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


main()

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

print(sum(A))

Submission status: Time Limit Exceeded

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

#print(an)
for i in range(m):
    an[0] = an[0] // 2
    for ii in range(1, n-1):
        if an[0] < an[ii]:
            an[0], an[ii] = an[ii], an[0]
    #print(an)

print(sum(an))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

Submission status: Time Limit Exceeded

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

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

    for i in range(m):
        j = a.index(max(a))
        a[j] = a[j] >> 1

    print(sum(a))

if __name__ == '__main__':
    ans()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

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

A = list(map(int,input().split(" ")))
A.sort(reverse=True)
hmax = math.floor(A[0]/2)
index = 0
while M > 0:
    if index != len(A):
        if A[index] >= hmax:
            A[index] = math.floor(A[index]/2)
            M = M -1
            index = index + 1
        else:
            index = 0
            A.sort(reverse=True)
            hmax = math.floor(A[0])
    else:
        index = 0
print(sum(A))

Submission status: Time Limit Exceeded

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

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

for _ in range(m):
    val=a.pop()//2
    bisect.insort(a, val)

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
A = list(map(float, input().split()))
i=0
while i<m:
  i+=1
  tukaubasho=A.index(max(A))
  A[tukaubasho]=A[tukaubasho]/2
output=0
for a in A:
	output=output+(a//1)
print(int(output))

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

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

for i in range(M):
    # j = A.index(max(A))
    # j = A.argmax()
    # A[A.argmax()] //= 2
    A.sort()
    A[N-1] //= 2

print(sum(A))

Submission status: Time Limit Exceeded

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

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

for _ in range(M):
    # a[a.argmax()] //= 2
    a.sort()
    a[-1] //= 2
print(sum(a))