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

n, m = map(int, input().split())
a = numpy.array(list(map(int, input().split())))
for i in range(m):
    b = numpy.argmax(a)
    a[b] = a[b]//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):
    j = max(enumerate(a), key=lambda x: x[1])[0]
    a[j] //= 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.append(0)
A.sort(reverse=True)
now=0
B=[]
B.append(A[0])
line=0
total=0
while M>0:
    M-=1
    A[B.index(max(B))]=A[B.index(max(B))]//2
    B[B.index(max(B))] = B[B.index(max(B))] // 2
    now=B.index(max(B))
    #print(A)
    #print(B)
    if A[now]<A[line+1] and line<N-1:
        line+=1
        B.append(A[line])

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect


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

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

import sys
import math
import re

while m>0:
    a.sort()
    a[-1]=a[-1]//2
    m-=1;
print(sum(i for i in a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    n,m = map(int, input().split())
    a_list = list(map(int, input().split()))
    a_list = sorted(a_list, reverse=True)

    while m > 0:
        max_index = a_list.index(max(a_list))
        a_list[max_index] = a_list[max_index] // 2
        m-=1

    answer = sum(a_list)
    print(answer)

Submission status: Time Limit Exceeded

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

A.sort(reverse=True)

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(sum(A))

Submission status: Time Limit Exceeded

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

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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N,M = map(int, sys.stdin.readline().split())
list_A = list(map(int, sys.stdin.readline().split()))

for i in range(M):
    # list_A.sort(reverse=True)
    idx_max = list_A.index(max(list_A))
    list_A[idx_max] = int(list_A[idx_max]/2) 

ans = 0

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

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

print(total)

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

A_list = []

for A in input_A_list.split():
    bisect.insort(A_list, int(A))

for i in range(M):
    new_A = A_list.pop() // 2
    bisect.insort(A_list, new_A)

print(sum(A_list))

Submission status: Time Limit Exceeded

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

# N: 品物の数、M: 割引券の枚数
# A: 品物の値段のリスト。

A.sort(reverse=True)

# waribiki_zumi = []

# for i in range(M):
# 	if A[0] > waribiki_zumi[0]:
# 		waribiki_zumi.append(A[0]//2)
# 		del A[0]


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

	if N != 1:
		del A[0]
		for j in range(len(A)):
			if new_a > A[j]:
				A.insert(j, new_a)
				break

			if j == len(A)-1:
				A.append(new_a)

	else:
		A[0] = new_a

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect
N,M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
for m in range(M):
    i = bisect.bisect_left(A, A[-1]/2)
    A.insert(i, A[-1]/2)
    A.pop()
print(sum(map(int, A)))

Submission status: Time Limit Exceeded

Solution code:
n1, n2 = [int(i) for i in input().split()]
n3 = [int(i) for i in input().split()]

n3.sort(reverse = True)
n4 = []
for i1 in range(n2):
    if i1 != 0:
        if len(n3) == 0:
            n4[0] = n4[0] // 2
        elif n3[0] <= n4[0]:
            n4[0] = n4[0] // 2
        else:
            n4.append(n3[0] // 2)
            n3 = n3[1:len(n3)]
        n4.sort(reverse = True)
    else:
        n4.append(n3[0] // 2)
        n3 = n3[1:len(n3)]

r1 = 0
for i2 in range(len(n3)):
    r1 += n3[i2]
for i3 in range(len(n4)):
    r1 += n4[i3]

print(r1)

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
li=list(map(int,input().split()))
#li=list(map(jo,li))
#print(li)
for i in range(M):
    maxi=max(li)//2
    li.remove(max(li))
    li.append(maxi)
print(sum(li))

Submission status: Time Limit Exceeded

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

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

for i in range(M):
    A.sort(reverse=True)
    A[0] //= 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):
    j = max(enumerate(a), key=lambda x: x[1])[0]
    a[j] /= 2
for i in range(N):
    a[i] = math.floor(a[i])
print(sum(a))

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

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

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

out_list = [item for item in A_list]

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

print(sum(out_list))

Submission status: Time Limit Exceeded

Solution code:
import sys

def main():
	input = sys.stdin.readline

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

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

		# larger = N
		# smaller = -1
		# while larger-smaller!=1:
		# 	ind = int((larger+smaller)/2)
		# 	if A[0]>A[ind]:
		# 		smaller = ind
		# 	else:
		# 		larger = ind

		# A.insert(larger,A[0])

		ind = 0
		if N!=1:
			while A[ind]<A[ind+1]:
				A[ind], A[ind+1] = A[ind+1], A[ind]
				ind = ind+1
				if ind==N-1:
					break

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

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

for i in range(m):
  a = aaa.pop(-1) // 2
  insert_index = bisect.bisect_right(aaa, a)
  aaa.insert(insert_index, a)
  
print(sum(aaa))

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

    print(sum(a))

if __name__ == '__main__':
    ans()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math

N , M = map(int, input().split())
A = list(map(int , input().split()))
np_list = np.array(A)
#print(A)
for _ in range(M):
    #print(np_list)
    max_index = np_list.argmax()
    #print(max_index)
    np_list[max_index] = np_list[max_index] / 2
A = list(map( lambda x : math.floor(x) , A ))
print(sum(np_list))

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):
    max_point = data.index( max(data) )
    data[max_point] = power(data[max_point], 1)

print(sum(data))

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)

for i in range(M):
  x = A.argmax()
  if A[x] == 0:
    break
  A[x] >>= 1

print(sum(A))

Submission status: Time Limit Exceeded

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

from math import floor

def bubble(x):
	for i in range(len(x)-1):
		if x[i] < x[i+1]:
			x[i], x[i+1] = x[i+1], x[i]
		else:
			break

	return x

a.sort(reverse=True)

for _ in range(m):
	a[0] /= 2
	a = bubble(a)

ans = 0
for ele in a:
	ans += floor(ele)

print(ans)

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

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

# N: 買う品物の個数
# M: 持っている割引券の数
N, M = list(map(int, input().split()))

# X 円の品物を買う際に Y 枚の割引券を使った場合、その品物を (X/2^Y) 円(小数点以下切り捨て)で買うことができます。
# 最小で何円あれば全ての品物を買うことができるのか?

# アイディア
# 単に高い商品から順に割引券を使えればよい...
# ただ、割引券は 10^5 枚ありえるようなので、
# 普通に並び替えて最大なものに割引券を適用する...というのを繰り返しても、
# タイムアウトになるだろう。
# うーん...
#
# 単に大きい順にソートして割引券を適用して、
# そのあとは挿入ソートを使って順繰りに割引券を適用するというのはどうだろうか
# やってみようか
A = list(map(int, input().split()))
A.sort(reverse=True)
# print(A)

for i in range(M):
    # 1. 先頭を半額にする
    # 2. 挿入ソートする (最初は手抜きでタイムアウトするか調べる)
    A[0] = A[0] / 2
    A.sort(reverse=True)

print(sum([int(x) for x in A]))

Submission status: Time Limit Exceeded

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

for ii in range(m):
    a_new[0] = int(a_new[0]/2)
    a_new= sorted(a_new)[::-1]

print(sum(a_new))

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

Submission status: Time Limit Exceeded

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

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

print(sum(list1))

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in range(M):
    price.sort(reverse=True)
    price[0] = math.floor(price[0] / 2)
print(sum(price))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#S = input()
N,M = map(int,input().split())
A_list = list(map(int,input().split()))
#X1_list = [int(input()) for i in range(N)]
#X2_list = [list(map(int,input().split())) for i in range(N)]

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

Submission status: Time Limit Exceeded

Solution code:
'use strict'
import math

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

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

print(sum(goods_price_list))

Submission status: Time Limit Exceeded

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

print(sum(item))

Submission status: Time Limit Exceeded

Solution code:
import math

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))] = math.floor(max(a)/2)
    if max(a)==0:
        break
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:
    a.sort()
    a[-1]=a[-1]//2
    m-=1;
print(sum(i for i in a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

for i in range(M):
    x = B.pop()
    bisect.insort(B, x/2)
    if i + 1 > M - N:
        C.append(B.pop(0))
print(sum(map(int, B + C)))

Submission status: Time Limit Exceeded

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

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

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import sys
import numpy as np

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

for i in range(M):
    #max_a = A_list.max()
    index = A_list.argmax()
    A_list[index] = np.floor(A_list[index] / 2)
    
print(np.sum(A_list))

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):
    mm = max(A)
    ii = math.floor(mm/2)
    ind = A.index(mm)
    A[ind] = ii
 
print(int(sum(A)))

Submission status: Time Limit Exceeded

Solution code:

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

Tmp = []
Tmp = input().rstrip().split(' ')

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

for i in range(N):
  P[i] = int(Tmp[i])

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

Ans = 0
for i in range(N):
  Ans += P[i] // 1

print('%d' %(Ans))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

from bisect import insort

for _ in range(m):
    x = A.pop()//2
    insort(A, x)

print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

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

print(sum(a_l))

Submission status: Time Limit Exceeded

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

c=sorted(list(map(int,input().split())))

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

print(sum(c))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


def InputToInt():
    A = input().split()
    for i in range(len(A)):
        A[i] = int(A[i])
    return np.array(A)
    
if __name__ == '__main__':
    N, M = InputToInt()
    A = InputToInt()
    A = np.sort(A)[::-1]
#    print(A)
    for i in range(M):
        A[0] = A[0]//2
        A[0:min(i+2,N)] = np.sort(A[0:min(i+2,N)])[::-1]
#        print(A)
    print(sum(A))

Submission status: Time Limit Exceeded

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

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

C = [0] * M
if N == 1:
    for i in range(M):
        A[0] = A[0] // 2
    print(A[0])
    exit(0)

while(M > 0):
    A.sort(reverse=True)
    A[0] = A[0] // 2
    M -= 1
print(sum(A))

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
        a //= 2
        M -= 1
        bisect.insort(A, a)
    print(sum(A))

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
li = list(map(int, input().split()))
for i in range(m):
    u = 0
    for j, k in enumerate(li):
        if k == max(li) and u == 0:
            li[j] = max(li) // 2
            u = 1
print(sum(li))

Submission status: Time Limit Exceeded

Solution code:
def main():
  n, m = map(int, input().split(' '))
  al = list(map(int, input().split(' ')))
  for _ in range(m):
    al[find_max_index(al)] //= 2
  print(sum(al))

def find_max_index(l):
  index = 0
  M = l[index]
  for i in range(len(l)):
    if l[i] > M:
      index = i
      M = l[index]
    else:
      pass
  return index

if __name__ == '__main__':
  main()

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

Submission status: Time Limit Exceeded

Solution code:
a=input().split(" ")
N=int(a[0])
M=int(a[1])
b=input().split(" ")
list_price=[]
for i in range(N):
    list_price.append(int(b[i]))

for i in range(M):
    list_price[list_price.index(max(list_price))]=(list_price[list_price.index(max(list_price))]/2)//1
print(int(sum(list_price)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N,M=map(int,input().split())
# N,M=3,3
A = list(map(int,input().split()))
#dymmy
# A.append(-1)
# A=[2,13,8]
# print(np.argmax(A))

# print(N,M,A)
# Val = sorted(A,reverse=True)
# print("割引前",Val)

#Ｍ枚の商品券を持っているため
for i in range(M):
    A[np.argmax(A)]= A[np.argmax(A)]//2
    # if Val[0] < Val[1]:
        # Val = sorted(Val,reverse=True)

# print("計算後",Val)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
from bisect import insort


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


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(int(s[1])):
    j = A.index(max(A))
    A[j] //= 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()]
A.sort(reverse=True)
A1=A[:M]
A2=A[M:]

for i in range(M):
    A1.sort(reverse=True)
    if len(A1)>M-i:
        A2.append(A1[-1])
        del A1[-1]
    A1[0]=A1[0]//2

print(sum(A1)+sum(A2))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A = sorted(A,reverse=True)
temp = 0
for i in range(M):
    A[0] =A[0]//2
    if len(A)>=2:
        if A[0] < A[1]:
            A = sorted(A,reverse=True)
print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

A.sort()
tmp = A.pop(-1)
index = 0
for _ in range(M):
  tmp //= 2
  index = bisect.bisect_right(A,tmp)
  if index < N - 1:
    bisect.insort_right(A, tmp)
    tmp = A.pop(-1)
A.append(tmp)

print(sum(A))

Submission status: Time Limit Exceeded

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

A.sort(reverse=True)
for _ in range(M):
    buf=A[0]//2
    i=1
    if N>2:
        while buf<A[i]:
            A[i-1]=A[i]
            i+=1
            if i==N:
                break
    A[i-1]=buf
print(int(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):
  makks = max(A)
  if makks == 0:
    break
  A.remove(max(A))
  A.append(makks // 2)
S = 0
for j in range(len(A)):
  S += A[j]
print(S)

Submission status: Time Limit Exceeded

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

A.sort()

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

print(sum(A))

Submission status: Time Limit Exceeded

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

s = input()
prices = s.split()
prices = list(map(int, prices))

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

for i in range(M): #　半額券の数だけループ
    prices.sort(reverse = True)
    prices[0] = int(prices[0] / 2)

print(sum(prices))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding=utf-8

import bisect


if __name__ == "__main__":
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()

    for i in range(M):
        now = A.pop()
        now /= 2
        insert_index = bisect.bisect_left(A, now)
        A = A[:insert_index] + [now] + A[insert_index:]
    A = list(map(int, A))
    print(sum(A))

Submission status: Time Limit Exceeded

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

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

A.sort(reverse=True)

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

print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    stuff = list(map(int, input().split()))

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

    print(sum(stuff))


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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
if __name__ == "__main__":
  n, m = list(map(int, input().split())) 
  A = list(map(int, input().split()))
  A = np.array(A)

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

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

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

Submission status: Time Limit Exceeded

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

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

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys, bisect

def main():
    N,M,*A = map(int, open(0).read().split())

    A.sort()
    for _ in range(M):
        a = int(A.pop() / 2)
        bisect.insort_left(A,a)

    print(sum(A))

if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

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

A_int=[int(x) for x in A]
print(sum(A_int))

Submission status: Time Limit Exceeded

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

b = [0] * n

a.sort(reverse=True)

i = 0

if n == 1:
    print(a[0] // pow(2, m))
else:
    while m > 0:
        if i > n:
            break
        if a[0] >= a[1]:
            a[0] = a[0] // 2
            m -= 1
        else:
            for i in range(n - 1):
                if a[i] < a[i + 1]:
                    a[i], a[i + 1] = a[i + 1], a[i]
                else:
                    break
    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(int(np.sum(np.floor(A))))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

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

A.sort(reverse=True)
for _ in range(M):
    A[0] //= 2
    temp = A[0]
    for i in range(1, N):
        if (A[i] < temp):
            A.insert(i, temp)
            A = A[1:]
            break

print(sum(A))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
while True:
    try:
        n, m = map(int, input().split())
        lst = list(map(int, input().split()))
        for i in range(m):
            temp = max(lst)
            lst[lst.index(temp)] = temp // 2
        print(sum(lst))
    except:
        break

Submission status: Time Limit Exceeded

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