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 math

N, M = list(map(int, input().split()))
price = list(map(int, input().split()))
total = sum(price)
for i in range(M):
    max_index = price.index(max(price))
    discount = math.ceil(max(price) / 2)
    total -= discount
    price[max_index] -= discount
print(total)

Submission status: Time Limit Exceeded

Solution code:
n, m = list(map(int, input().split()))
lisA = [int(i) for i in input().split()]
#print(n, m)
#print(lisA)

lisA.sort(reverse=True)
lenA = len(lisA)
half0 = lisA[0]
count = 0
for i in range(m):
	if (count > lenA - 1):
		count = 0
	if (lisA[count] < half0):
		lisA.sort(reverse=True)
		half0 = lisA[0]
		count = 0
	lisA[count] /= 2
	count += 1
answer = 0
for i in range(n):
	answer += int(lisA[i])
print(answer)

Submission status: Time Limit Exceeded

Solution code:
import os

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

for i in range(0,M):
    list.sort()
    list[len(list)-1] = list[len(list)-1]//2

ans = 0
for j in list:
    ans += j
print(ans)

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.sort()    
    list1[n-1] //= 2

print(sum(list1))

Submission status: Time Limit Exceeded

Solution code:
import math

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

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


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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import sys
import math
# import numpy
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()))
list_A.sort(reverse=True)

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:
N,M= map(int,input().split())
A = list(map(int,input().split()))
if len(A) > 1:
    ind = A.index(max(A))
    top = A.pop(ind)
    sec = max(A)
    for i in range(M):
        top = top/2
        if top < sec:
            A.append(top)
            top = A.pop(A.index(max(A)))
            sec = max(A)
    A.append(top)
    A =list(map(int,A))
    print(sum(A))
else:
    print(int(A[0]/(2**M)))
    # ind = A.index(max(A))
    # A[ind] = A[ind]/2
    # print(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)
  a[-1]=a[-1]//2
print(sum(a))

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]
    # discount
    price_1st = price_1st // 2
    if price_1st >= price_2nd:
        Prices[HighPriceIdx] = price_1st
    else:
        Prices[HighPriceIdx] = price_2nd
        Prices[HighPriceIdx+1] = price_1st
        Prices.sort(reverse=True)

    M = M - 1

print(sum(Prices))

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
    if al[find_max_index(al)] <= 0:
      break
  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:
n,m = map(int,input().split())
a_list = list(map(int,input().split()))
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:
n, m = (int(x) for x in input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数liに代入。

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 bisect

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

for _ in range(M):
    a = A2.pop()
    a2=a>>1
    bisect.insort_right(A2,a2)
    #print(A2)

print(sum(A2))

Submission status: Time Limit Exceeded

Solution code:
n,m = list(map(int,input().split()))
a = 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:
import numpy as np
N, M = map(int, input().split())
items = np.array(list(map(int, input().split())))
for i in range(M):
    items[items.argmax()]/=2
print(round(np.sum(items)))

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:
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
for _ in range(M):
  A[N-1] //= 2
  A.sort()
print(sum(A))

Submission status: Time Limit Exceeded

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

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

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

count = 0
for i in A:
    count += i

print(count)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
A=list(map(int, input().split()))
B=[]
C=N//10+1
if N>C:
    for x in range(0,M):
        if x==0:
            A.sort()
            B=A
            A=A[:-C]
            B=B[-C:]
        B.sort()
        if A[-1]>B[0]:
            A[len(A):len(B)]=B
            A.sort()
            B=A
            A=A[:-C]
            B=B[-C:]
        B[-1]=B[-1]//2
else:
    for x in range(0,M):
        A.sort()
        A[-1]=A[-1]//2
A[len(A):len(B)]=B
print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(m):
    ss = sorted(ss, reverse = True)
    ss[0] = math.floor(ss[0]/2)

print(sum(ss))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n,m = map(int,input().split())
list_a = list(map(int,input().split()))
#b_list = list(map(int,input().split()))
#print(" ".join(map(str,c_list)))

for i in range(m):
    a = np.argmax(list_a)
    list_a[a] = list_a[a] // 2
    """
    if list_a[0] % 2 != 0:
        list_a[0] = list_a[0] // 2 - 1
    else:
        list_a[0] = list_a[0] // 2
    """
print(sum(list_a))

Submission status: Time Limit Exceeded

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

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

print(sum(Alist))

Submission status: Time Limit Exceeded

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

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


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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import copy

def solve(N: int, M: int, A: "List[int]"):
    A = sorted(A, reverse=True)
    for m in range(M):
        A[0] = A[0] // 2
        if (len(A) >= 2) and (A[0] < A[1]):
            tmp = A[0]
            del A[0]

            #B = copy.deepcopy(A)
            for i, a in enumerate(A):
                if a <= tmp:
                    A.insert(i, tmp)
                    break
                if i == len(A)-1:
                    A.insert(len(A)-1, tmp)
                    break
            #A = B
    print(sum(A))
    return




# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
l=list(map(int,input().split()))
sl=sorted(l)[::-1]
for i in range(M):
	sl[0]=sl[0]//2
	sl=sorted(sl)[::-1]
else:
	print(sum(sl))

Submission status: Time Limit Exceeded

Solution code:

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

for i in range(l[1]):
    prices.sort(reverse = True)
    prices[0] = int(prices[0] / 2)

print(sum(prices))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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



a=list(map(int,input().split()))
for i in range(m):
	a.sort()
	a[-1]=a[-1]//2
	#print(a)
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
    if max(A) == 0:
       break
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys
import heapq
n, m = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))
for i in range(n):
    A[i] = -A[i]
heapq.heapify(A)
#(A)
for j in range(m):
    A[0] = int(A[0]/2)
    #print(A)
    heapq.heapify(A)

print(-sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math

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

for i in range(M):
  if (A[N - 1] < A[N - 2]):
    A.sort()
  A[N - 1] /= 2.0
amount = 0
for a in A:
  amount += math.floor(a)
print(amount)

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)

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

    answer = sum(a_list)
    print(answer)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import math

nm = input()
a = input()

nm = nm.split()
n = int(nm[0])
m = int(nm[1])
a = a.split()
a = [int(x) for x in a]

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

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

print(output)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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 = [] #price 0 - n-1
A_tmp = input()
A = [int(x.strip()) for x in A_tmp.split(' ')]
A.sort(reverse=True)
for i in range(0, M):
    A[0] = A[0]/2
    A.sort(reverse=True)
for i in range(0, N):
    A[i] = math.floor(A[i])
print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(m):
  b = max(a)
  a.remove(b)
  b = int(b/2)
  a.append(b)
  
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
ls.sort(reverse=True)
#print(ls)
for i in range(M):
  x=max(ls)
  y=x//2
  ls[ls.index(x)]=y
print(sum(ls))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np 

n, m = map(int, input().split()) 
A = [int(a) for a in input().split()]
if len(A) == 1:
    print(A[0]//(2**m))

else:
    A = np.array(A)
    A = np.sort(A)[::-1]


    for i in range(m):
        if i == 0:
            A[0] /= 2
        else:
            if A[0] < A[1]:
                A[1] /= 2
                A = np.sort(A)[::-1]
            else:
                A[0] /= 2

    A = [int(a) for a in A]
    print(sum(A))

Submission status: Time Limit Exceeded

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

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


mycnt = 1
while mycnt <= M:
    mylist[mylist.index(max(mylist))] = max(mylist)//2
    #print(mylist[mylist.index(max(mylist))])
    mycnt += 1

mysum = sum(mylist)


    

print(mysum)

Submission status: Time Limit Exceeded

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

n, m = map(int, input().split())
#aaa = list(map(int, input().split()))
aaa = [int(a) for a in 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:
import numpy

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

for i in range(M):
    # j = max(enumerate(a), key=lambda x: x[1])[0]
    j = a.argmax()
    a[j] //= 2
print(sum(a))

Submission status: Time Limit Exceeded

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

for i in range(M):
  #print(A)
  idx = A.index(max(A))
  A[idx] = A[idx] // 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):
    max_item_index = A.index(max(A))
    A[max_item_index] = int(A[max_item_index] / 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):
    x = a.pop()
    x = x / 2
    bisect.insort(a, x)



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

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] = a[num] // 2

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N, M = list(map(int, input().split(' ')))
x = np.array(list(map(int, input().split(' '))))
for m in range(M):
    if np.sum(x) == 0:
        break
    x = np.sort(x)[::-1]
    x[0] = np.trunc(x[0]/2.0)
print(np.sum(x))

Submission status: Time Limit Exceeded

Solution code:
import sys
from bisect import insort_left
INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
sys.setrecursionlimit(10 ** 9)


def main():
    N, M = MAP()
    A = LIST()
    A = sorted(A)

    for _ in range(M):
        value = A[-1] // 2
        A.pop(-1)
        insort_left(A, value)

    print(sum(A))


if __name__ == '__main__':
    main()

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

print(sum(data))

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# n = int(input())
n, m = map(int, input().split())
a = input()
a_list = [int(x.strip()) for x in a.split()]

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:
#!/usr/bin/env python3
import sys
import copy

def solve(N: int, M: int, A: "List[int]"):
    A = sorted(A, reverse=True)
    for m in range(M):
        A[0] = int(A[0] / 2)
        if len(A) > 1 and A[0] < A[1]:
            tmp = A[0]
            del A[0]

            B = copy.deepcopy(A)
            for i, a in enumerate(A):
                if a <= tmp:
                    B.insert(i, tmp)
                    break
                if i == len(A)-1:
                    B.insert(len(A)-1, tmp)
            A = B
    print(sum(A))
    return




# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n, m = tuple(map(int, input().split()))
a = list(map(int, input().split()))
for _ in range(m):
    v = max(a)
    a[a.index(v)] = int(v/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]
ans=sum(A[M:])

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

print(sum(A1)+ans)

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
    t=B.index(max(B))
    A[t]=A[t]//2
    B[t] = B[t] // 2
    now=t
    #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:
s=list(input().split())
N=int(s[0])
M=int(s[1])
count=0
total=0
a = list(map(int,input().split()))	
while(count<M):
  a[a.index(max(a))]=a[a.index(max(a))]//2
  count+=1

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

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse=True)

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

a.sort()

for _ in range(m):
    tgt = a.pop()
    tgt //= 2
    bisect.insort(a, tgt, lo=max(0, (n-m)))

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

A_list = []

for i in range(N):
    A = input_A_list.pop()
    bisect.insort(A_list, 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(" "))
As = map(int, input().split(" "))
As = sorted(As)
for _ in range(M):
    a = As.pop()
    a /= 2
    As.append(int(a))
    As = sorted(As)
print(sum(As))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
A=list(map(int, input().split()))
B=[]
if N>10:
    for x in range(0,M):
        if x==0:
            A.sort()
            B=A
            A=A[:-10]
            B=B[-10:]
        B.sort()
        if A[-1]>B[0]:
            A[len(A):len(B)]=B
            A.sort()
            B=A
            A=A[:-10]
            B=B[-10:]
        B[-1]=B[-1]//2
else:
    for x in range(0,M):
        A.sort()
        A[-1]=A[-1]//2
A[len(A):len(B)]=B
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

n, m = map(int, input().split())
l = [int(n) for n in input().split()]

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

Submission status: Time Limit Exceeded

Solution code:
import sys, bisect

def main():
    _,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:
n,m = map(int,input().split())
a_list = list(map(int,input().split()))
for i in range(m):
    max_index = a_list.index(max(a_list))
    a_list[max_index] //= 2
print(sum(a_list))

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

for i in range(int(s[1])):
    # j = A.index(max(A))
    j = A.argmax()
    A[j] //= 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):
    a = A.pop(-1)//2
    bisect.insort_left(A,a)

print(sum(A))

Submission status: Time Limit Exceeded

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

    if N == 1:
        print(math.floor(stuff[0] / (2**M)))
        sys.exit()

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

A.sort(reverse=True)

for i in range(M):
    if i == 0:
        A[0] = A[0]//2
    else:
        temp = A[0]
        idx = 0
        j = 0
        while j < N and j <= i:
            if temp < A[j]:
                temp = A[j]
                idx = j
            j += 1
        A[idx] = A[idx]//2
        
print(sum(A))

Submission status: Time Limit Exceeded

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

while(m>0):
    a[a.index(max(a))] //=2
    m-=1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
#D

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

print(sum(list(map(math.floor,list1))))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

N, M, *A, = map(int, open(0).read().split())
for _ in range(M):
    A[A.index(max(A))] = A[A.index(max(A))] // 2
print(sum(A))

Submission status: Time Limit Exceeded

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

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

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

# output
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_left

for _ in range(m):
    x = A.pop()//2
    insort_left(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 m in range(M):
    list.sort(A, reverse=True)
    A[0] = int(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()))
A.sort(reverse=True)
if N == 1:
    for i in range(M):
        A[0] = A[0] // 2
else:
    for i in range(M):
        if A[0] >= A[1]:
            A[0] = A[0] // 2
        else:
            A[1] = A[1] // 2
            A.sort(reverse=True)
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
import bisect
n, ticket = map(int, input().split())
L = list(map(int, input().split()))


if len(L) == 1:
    print(math.floor(L[0] / (2**ticket)))
else:
    L.sort()
    for _ in range(ticket):
        top = L.pop()
        top /= 2
        bisect.insort_left(L,top)
    print(sum(map(math.floor, L)))

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
  if max(value) == 0:
    break
ans = 0
for i in range(n):
  ans += value[i]
print(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()))
A = np.array(A)

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

print(A.sum())

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:

N,M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(M):
  p = A.index(max(A))
  A[p] = int(A[p]/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):
	max_index = A.index(max(A))
	A[max_index] = int(A[max_index]/2)

print(sum(A))

Submission status: Time Limit Exceeded

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

while m > 0:
    a_list.sort(reverse=True)
    a_list[0] = a_list[0] // 2
    m -= 1

cost_sum = 0
for a in a_list:
    cost_sum += a

print(cost_sum)

Submission status: Time Limit Exceeded

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

sorted_S = [i for i in reversed(sorted(S))]
max_index = 0

for i in range(M):

    sorted_S[max_index] = int(sorted_S[max_index]/2)
    sorted_S = [i for i in reversed(sorted(sorted_S))]

print(sum(sorted_S))

Submission status: Time Limit Exceeded

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

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

mylist.sort(reverse=True)


mysum = sum(mylist)

mycnt = 1
while mycnt <= M:
    mylist[mylist.index(max(mylist))] = max(mylist)//2
    #print(mylist[mylist.index(max(mylist))])
    mycnt += 1

mysum = sum(mylist)


    

print(mysum)

Submission status: Time Limit Exceeded

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

temp = list(map(int, input().split()))
N = temp[0] #品物の数
M = temp[1] #割引券の枚数
A = list(map(int, input().split())) #品物の値段のリスト

while(M>0):
  A.sort()
  A[N-1] = A[N-1]//2
  M -= 1

print(sum(A))