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:
# ABC141 D -Powerful Discount Tickets

import numpy

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

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

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

print(sum(int_A))

Submission status: Time Limit Exceeded

Solution code:
#problem-D
def discount(array):
    array.sort()
    array[-1] = array[-1]//2
    return array

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

for i in range(m):
    discount(price)
print(sum(price))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

A_list = sorted(A_list)
#print(A_list)

for i in range(M):
    val = A_list.pop()//2
    bisect.insort_left(A_list, val, lo=min(N-1, max(0,(N-M) + i)) )

print(sum(A_list))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

A_list = sorted(A_list)
#print(A_list)

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

print(sum(A_list))

Submission status: Time Limit Exceeded

Solution code:
import heapq
import math
n,m = map(int,input().split())
lst = [int(x) * (-1) for x in input().split()]
heapq.heapify(lst)
for use_cnt in range(m):
    num = heapq.heappop(lst) * -1
    nxt_num = math.floor(num / 2)
    heapq.heappush(lst,nxt_num * -1)
    if sum(lst) == 0:
        break
print(sum(lst) * (-1))

Submission status: Time Limit Exceeded

Solution code:
import heapq
import math
n,m = map(int,input().split())
lst = [int(x) * (-1) for x in input().split()]
heapq.heapify(lst)
for i in range(m):
    num = heapq.heappop(lst) * (-1)
    nxt_num = math.floor(num / 2)
    heapq.heappush(lst,nxt_num * -1)
    if sum(lst) == 0:
        break
print(sum(lst) * (-1))

Submission status: Time Limit Exceeded

Solution code:
import heapq
import math

n,m = map(int,input().split())
lst = list(map(int,input().split()))
lst = list(map(lambda x:x*(-1),lst))
heapq.heapify(lst)
for i in range(m):
    num = heapq.heappop(lst) * (-1)
    nxt_num = math.floor(num / 2)
    heapq.heappush(lst,nxt_num * -1)
    if sum(lst) == 0:
        break
print(sum(lst) * (-1))

Submission status: Time Limit Exceeded

Solution code:
import heapq
import math
n,m = map(int,input().split())
lst = list(map(int,input().split()))
lst = list(map(lambda x:x*(-1),lst))
heapq.heapify(lst)
for i in range(m):
    num = heapq.heappop(lst)
    num = math.ceil(num / 2)
    heapq.heappush(lst,num)
    if sum(lst) == 0:
        break
print(sum(lst) * (-1))

Submission status: Time Limit Exceeded

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

A.sort()

def discount(A,M,N):
    cost=0
    for i in range(len(A)):
        cost+=A[i]
    while M>0:
        cost=cost-A[N-1]+A[N-1]//2
        M-=1
        A[N-1]//=2
        A.sort()
    return cost

print(discount(A,M,N))

Submission status: Time Limit Exceeded

Solution code:
import bisect 
n,m = map(int,input().split())
lst = sorted(list(map(int,input().split())))
for i in range(m):
    num = lst[-1] // 2
    pos = bisect.bisect_left(lst,num)
    lst = lst[:pos] + [num] + lst[pos:-1]
    if sum(lst) == 0:
        break
print(sum(lst))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:


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

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


while True:
  A[A.index(max(A))] //=2
  M -=1
  if M <=0:
    break

print(sum(A))

Submission status: Time Limit Exceeded

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

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

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

print(sum(np_A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import heapq

def calc_minus(n):
    return n * (-1)

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

values_minus = []
for val1 in values:
    values_minus.append(calc_minus(val1))

for i in range(M):
    heapq.heapify(values_minus)
    tmp = heapq.heappop(values_minus)
    tmp_push = ((tmp * (-1)) // 2) * (-1)
    heapq.heappush(values_minus, tmp_push)

values_plus = []
for val2 in values_minus:
    values_plus.append(calc_minus(val2))

result = 0
for val3 in values_plus:
    result += val3

print(result)

Submission status: Time Limit Exceeded

Solution code:
import sys
n,m = map(int,input().split())
lst_a = list(map(int,input().split()))
lst_a.sort(reverse=True)
temp = 0
ans = 0
if n == 1:
    for i in range(m):
        lst_a[0] //= 2
    print(lst_a[0])
    sys.exit()
for i in range(m):
    if lst_a[0] >= lst_a[1]:
        lst_a[0] //= 2
    else:
        lst_a[1] //= 2
        lst_a.sort(reverse=True)
print(sum(lst_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))]//=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]//=2

print(sum(a))

Submission status: Time Limit Exceeded

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

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

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

def max_heapsort(iter):
    for i in reversed(range(len(iter)//2)):
        max_heapify(iter,i)

def max_heapify(array,i):
    left = 2*i+1
    right = 2*i+2
    length = len(array) - 1
    biggest = i

    if left <= length and array[i] < array[left]:
        biggest = left
    if right <= length and array[biggest] < array[right]:
        biggest = right
    if biggest != i:
        array[i], array[biggest] = array[biggest], array[i]
        max_heapify(array, biggest)

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)
        max_heapsort(A)
        
        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:
n,m = map(int,input().split(" "))
ar = list(map(int,input().split(" ")))
ar.sort()
for i in range(m):
    ar[-1] //= 2
    ar.sort()
print(sum(ar))

Submission status: Time Limit Exceeded

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

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 math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n,m = map(int,input().split())
    a = [x for x in map(int,input().split())]
    for i in range(m):
        id = a.index(max(a))
        a[id] //= 2
    print(sum(a))
    return

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()
A = LI()

A.sort()
for i in range(M):
    a_max = A.pop() // 2
    bisect.insort_left(A,a_max)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()
A = LI()

A.sort()
for i in range(M):
    a_max = A.pop(-1) // 2
    bisect.insort_left(A,a_max)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
N,M = LI()
A = LI()

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,(input().split(' ')))
a=list(map(int,input().split(' ')))
while m:
    m-=1
    r=max(a)
    a.remove(r)
    r//=2
    a.append(r)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import heapq
import math

ipt = input().split()
N = int(ipt[0]) #品物個数
M = int(ipt[1]) #割引券枚数

items = input().split()
#符合反転させる
int_items = [int(s)*-1 for s in items]

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

lst_items = heapsort(int_items)#小から大へ並び替えてリストに格納
#一番小さい数を2で割ってヒープソートをM回繰り返す
for i in range(M):
    lst_items[0] = math.ceil(lst_items[0] / 2)
    lst_items = heapsort(lst_items)

#全リスト要素を加算し符合反転
print(sum(lst_items)*-1)

Submission status: Time Limit Exceeded

Solution code:
def calc_half(n):
    return int(n /  2)

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

for m_num in range(m):
    max_index = a.index(max(a))
    a[max_index] = a_half[max_index]
    a_half[max_index] = calc_half(a_half[max_index])

print(sum(a))

Submission status: Time Limit Exceeded

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

A = input().split()
A = [int(n) for n in A]
#print('input A', A)

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

#print('N', N)
#print('M', M)
#print('A', A)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
x,y = map(int,input().split())
li = list(map(int,input().split()))
score = 0
for i in range(y):
  li[li.index(max(li))] //= 2
print(sum(li))

Submission status: Time Limit Exceeded

Solution code:
x,y = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
score = 0
for i in range(y):
  li[li.index(max(li))] //= 2
for j in li:
  score += j
print(score)

Submission status: Time Limit Exceeded

Solution code:
x,y = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
score = 0
for i in range(y):
  li[x - 1] //= 2
  if len(li) > 2:
    if li[x - 1] < li[x - 2]:
      li.sort()
for j in li:
  score += j
print(score)

Submission status: Time Limit Exceeded

Solution code:
x,y = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
score = 0
for i in range(y):
  li.sort()
  li[x - 1] //= 2
for j in li:
  score += j
print(score)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python3

import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
MOD = 10 ** 9 + 7

N, M = [int(x) for x in input().split()]
A = [int(x) for x in 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_list = list(map(int, input().split()))

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

print(sum(A_list))

Submission status: Time Limit Exceeded

Solution code:
n, m, *a = map(int, open(0).read().split())
new_a = sorted(a, reverse=True)
sum = 0
if n >= m:
    for price in new_a[m:]:
        sum += price
    new_a = new_a[:m]
    for _ in range(m, 0, -1):
        if new_a[0] < 1:
            break
        new_a[0] /= 2
        new_a.sort(reverse=True)
        sum += int(new_a[-1])
        new_a = new_a[:-1]
else:
    for i in range(m, 0, -1):
        if new_a[0] < 1:
            break
        new_a[0] /= 2
        new_a.sort(reverse=True)
        if n >= i:
            sum += int(new_a[-1])
            new_a = new_a[:-1]
for price in new_a:
    sum += int(price)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n, m, *a = map(int, open(0).read().split())
new_a = sorted(a, reverse=True)
sum = 0
for _ in range(m):
    new_a[0] /= 2
    new_a.sort(reverse=True)
for price in new_a:
    sum += int(price)
print(sum)

Submission status: Time Limit Exceeded

Solution code:
n, m, *a = map(int, open(0).read().split())
new_a = sorted(a, key=lambda x: -x)
sum = 0
for _ in range(m):
    new_a[0] /= 2
    new_a.sort(key=lambda x: -x)
for price in new_a:
    sum += int(price)
print(sum)

Submission status: Time Limit Exceeded

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

n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=-a[i]

for i in range(m):
    heapq.heapify(a)
    heapq.heappush(a,-(-heapq.heappop(a)//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()
#print(a)

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

n, m=map(int, input().split())
a=[int(n) for n in input().split()]
ans=0
cha=[]
a.sort()
if len(a)>m:
  for i in range(m):
    cha.append(a.pop())
else:
  for i in range(len(a)):
    cha.append(a.pop())
cha.sort()
for i in range(m):
  num=cha.pop()//2
  cha.insert(bisect.bisect_left(cha,num),num)


print(sum(cha)+sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

n, m=map(int, input().split())
a=[int(n) for n in input().split()]
ans=0
a.sort()
for i in range(m):
  num=a.pop()//2
  a.insert(bisect.bisect_left(a,num),num)
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


num_product, num_coupon = [int(s) for s in input().split()]
price_list = []
for s in input().split():
  heapq.heappush(price_list, int(s))

for i in range(num_coupon):
  max_price = max(price_list)
  for j in range(len(price_list)):
    if price_list[j] == max_price:
      price_list[j] //= 2
      break

sum = 0
for price in price_list:
  sum += price

print(sum)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
num_product, num_coupon = [int(s) for s in input().split()]
price_list = [int(s) for s in input().split()]

for i in range(num_coupon):
  max_price = max(price_list)
  for j in range(len(price_list)):
    if price_list[j] == max_price:
      price_list[j] //= 2
      break

sum = 0
for price in price_list:
  sum += price

print(sum)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
num_product, num_coupon = [int(s) for s in input().split()]
price_list = [int(s) for s in input().split()]
price_list.sort()
price_list.reverse()
discountable_price = price_list[0:num_coupon]

fixed_sum = 0

for price in price_list[num_coupon:]:
  fixed_sum += price

for i in range(num_coupon):
  discountable_price[0] //= 2
  discountable_price.sort()
  discountable_price.reverse()

sum = 0
for price in discountable_price:
  sum += price

sum += fixed_sum
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import bisect
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
for i in range(M):
  B = A.pop()
  bisect.insort_right(A,B//2)
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 i in range(M):
  B = A.pop()
  bisect.insort_right(A,B//2)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
 
num_product, num_coupon = [int(s) for s in input().split()]
price_list = [int(s) for s in input().split()]

for i in range(num_coupon):
  price_list.sort()
  price_list.reverse()
  price_list[0] //= 2

sum = 0
for price in price_list:
  sum += price
  
print(sum)

Submission status: Time Limit Exceeded

Solution code:
import bisect
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
for i in range(M):
  B = A.pop()
  bisect.insort_left(A,B//2)
print(sum(A))

Submission status: Time Limit Exceeded

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

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

for discount_i in range(m):
  max_item = max(item_list)
  target_index = item_list.index(max_item)
  item_list[target_index] = item_list[target_index]//2
  
print(sum(item_list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# D - Powerful Discount Tickets
n,m= map(int, input().split())

list = [int(s) for s in input().split()]

list.sort(reverse=True)

i = 0
while (m != 0):
    list[i] = (int)(list[i] / 2)
    m = m - 1
    if len(list) == 0:
        continue
    else:
        list.sort(reverse=True)

print(sum(list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(m):
    buy = max(a)
    a.remove(buy)
    a.append(int(buy/2))
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[prices.index(max(prices))] //= 2

print(sum(prices))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
s = list(map(int, input().split()))
#print(type(s))
for _ in range(m):
    max_value = max(s)
    max_index = s.index(max_value)
    s[max_index] = s[max_index] // 2

print(sum(s))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math
#math.floor
n, m = list(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
result = 0
for i in a:
    result += math.floor(i)
print(result)

Submission status: Time Limit Exceeded

Solution code:
import math
#math.floor

n, m = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
for i in range(m):
    b = a.pop(a.index(max(a)))
    b *= 1/2
    a.append(b)
result = 0
for i in a:
    result += math.floor(i)
print(result)

Submission status: Time Limit Exceeded

Solution code:
import sys
import copy
import math
import bisect
 
def dictCount(str):
    dict = {}
 
 
if __name__ == '__main__':
    n,m= map(int, input().split())
    a = [int(i) for i in input().split()]
    a.sort()
    half = a[n//2]
    for i in range(m):
        max = a.pop(n-1)
        max = max //2
        if max < half:
            bisect.insort_left(a, max)
        else:
            bisect.insort_right(a, max)
    sum = 0
    for i in a:
        sum = sum+i
    print(sum)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
N,Y=map(int,input().split())
a=[int(x) for x in input().split()]
for b in range(Y):
  a[a.index(max(a))]=a[a.index(max(a))]//2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
from heapq import heappush, heappop
N, K = list(map(int, input().split()))

Alist = [int(i) for i in input().split(' ')]
import math



Alist=sorted(Alist, reverse=True)

 


def insert_list(list, value):
	start=0
	end=len(list)-1

	if value<list[len(list)-1]:
		list.insert(len(list), value)
		return list
	if value>list[0]:
		list.insert(0, value)
		return list
	while True:
		mid_point=int((start+end)/2)
		if value>list[mid_point]:
			if (end-start)<2:
				list.insert(start, value)
				return list
			else:
				end=mid_point
		else:
			if (end-start)<2:
				list.insert(end, value)
				return list
			else:
				start=mid_point

for i in range(K):
   if N==1:
      Alist[0]=Alist[0]/2**K
      break
   Alist[0]=Alist[0]/2
   
   if len(Alist)>1:
      value=Alist.pop(0)
      Alist=insert_list(Alist,value)
sum=0

for i in Alist:
   sum+=math.floor(i) 
print(int(sum))

Submission status: Time Limit Exceeded

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

Alist = [int(i) for i in input().split(' ')]
import math

#print(Alist)
my_list = [9,8,7,4,7,1,3]

Alist=sorted(Alist, reverse=True)

def insert_list(list, value):
	start=0
	end=len(list)-1

	if value<list[len(list)-1]:
		list.insert(len(list), value)
		return list
	if value>list[0]:
		list.insert(0, value)
		return list
	while True:
		mid_point=int((start+end)/2)
		if value>list[mid_point]:
			if (end-start)<2:
				list.insert(start, value)
				return list
			else:
				end=mid_point
		else:
			if (end-start)<2:
				list.insert(end, value)
				return list
			else:
				start=mid_point

for i in range(K):
   Alist[0]=Alist[0]/2
   
   if len(Alist)>1:
      value=Alist.pop(0)
      Alist=insert_list(Alist,value)
sum=0
#print(Alist)
for i in Alist:
   sum+=math.floor(i) 
print(int(sum))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
lst = [int(i) for i in input().split()]
for i in range(m):
  idx, m = max(enumerate(lst), key=lambda ix: ix[-1])
  lst[idx] = m // 2
print(sum(lst))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
val = list(map(int,input().split()))
my_index = val.index
for i in range(m):
  val[my_index(max(val))] = max(val)//2
print(sum(val))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
list = [int(i) for i in input().split()]
while(m):
  list[list.index(max(list))] = max(list)//2
  m -= 1
print(sum(list))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(sum(list))

Submission status: Time Limit Exceeded

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

list_=sorted(list_)

for i in range(m):
    list_[-1]=list_[-1]/2
    list_=sorted(list_)

for i in range(n):
    list_[i]=int(list_[i])
    
print(sum(list_))

Submission status: Time Limit Exceeded

Solution code:
from heapq import*;n,m,*a=[-int(i)for i in open(0).read().split()];heapify(a);exec('heappush(a,0--heappop(a)//2);'*-m);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):
  num = a.index(max(a))
  a[num] = math.floor(a[num]/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))] = math.floor(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):
  i_max=A.index(max(A))
  A[i_max]=int(A[i_max]/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):
  i_max=np.argmax(A)
  A[i_max]=int(A[i_max]/2)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
goods, ticket = map(int, input().split())
list = list(map(int, input().split()))
sum = 0
for i in range(ticket):
  list.sort(reverse=True)
  list[0] //= 2
for j in list:
  sum += j
print(sum)

Submission status: Time Limit Exceeded

Solution code:
def main():
  N, M = map(int, input().split()) # スペース区切り入力
  A = list(map(int, input().split()))  # スペース区切り入力
  ans = 0
  # print(A)


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


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


  print(ans)


if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

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

Alist = [int(i) for i in input().split(' ')]
import math

#print(Alist)
my_list = [9,8,7,4,7,1,3]

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


for i in range(K):
   Alist[0]=Alist[0]/2
   Alist=sorted(Alist, reverse=True)
sum=0
#print(Alist)
for i in Alist:
   sum+=math.floor(i) 
print(int(sum))

Submission status: Time Limit Exceeded

Solution code:
import math
N,Y=map(int,input().split())
a=[float(x) for x in input().split()]
for b in range(Y):
  a.sort(reverse=True)
  a[0]=float(a[0])/2
v=0
for c in range(N):
  v+=int(a[c])
print(v)

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8
import math
N,Y=map(int,input().split())
a=[float(x) for x in input().split()]
for b in range(Y):
  a.sort(reverse=True)
  a[0]=float(a[0])/2
v=0
for c in range(N):
  v=v+math.floor(a[c])
print(v)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N > 1:
    for i in range(M):
        index = A.index(max(A))
        A[index] = A[index] >> 1
else:
    A[0] = A[0] >> M
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
import math
# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N > 1:
    for i in range(M):
        index = A.index(max(A))
        A[index] = math.floor(A[index] * 0.5)
else:
    A[0] = math.floor(A[0] * (1 / pow(2, M)))
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# https://atcoder.jp/contests/abc141/tasks/abc141_d
import math
# 整数の入力
N, M = map(int, input().split())
A = list(map(int, input().split()))
if N > 1:
    for i in range(M):
        A.sort(reverse=True)
        A[0] = math.floor(A[0] * 0.5)
else:
    A[0] = math.floor(A[0] * (1 / pow(2, M)))
print(sum(A))

Submission status: Time Limit Exceeded

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

#print(A)

for i in range(m):
    if i == 0:
        A[0] = A[0]//2
    else:
        list = A[0:i+1]
#        print(list)
        max_num = max(list)
        max_id = list.index(max_num)
        A[max_id] = max_num//2

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

Submission status: Time Limit Exceeded

Solution code:
#AtCoder

import sys
import math
import itertools
input = sys.stdin.readline

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

A.sort(reverse=True)

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

for _ in range(M):
	A[0] = A[0] // 2
	if A[0] < A[1]:
		left = 1
		right = N-1
		while left != right-1:
			if A[0] < A[(left+right)//2]:
				left = (left+right)//2
			else:
				right = (left+right)//2
		
		i = right
		head = A[1:i]
		head.append(A[0])
		tail = A[i:]
		A = head + tail


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

print(sum)



"""

"""