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:
def resolve():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    for i in range(m):
        m = a[-1]
        disc = m // 2
        a.pop()
        a.append(disc)
        a.sort()
    print(sum(a))


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
from math import log2, floor
n, m = map(int, input().split())
lst = [int(i) for i in input().split()]
lst.sort()
if n == 1:
    lst[0] //= 2 ** m
else:
    while m:
        x = floor(log2(lst[-1] / lst[-2])) + 1
        lst[-1] //= 2 ** x
        m -= x
        lst.sort()
print(sum(lst))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

if n == 1:
    a = int(input())
    for i in range(m):
        a //= 2
    print(a)
    exit()

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

for i in range(m):
    x = a.pop() // 2
    tmp = []
    for i in range(n):
        try:
            y = a.pop()
        except IndexError:
            a.append(x)
            a.extend(tmp[::-1])
            break

        if x < y:
            tmp.append(y)

        else:
            a.append(y)
            a.append(x)
            a.extend(tmp[::-1])
            break
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):
  s = a.index(max(a))
  a[s] = int(a[s] / 2)
 
print(sum(a))

Submission status: Time Limit Exceeded

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

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

for i in range(M):
    A[0] //= 2
    j = 0
    if len(A) > 1:
        while A[j] < A[j+1] and j < len(A):
            A[j] , A[j+1] = A[j+1], A[j]
            j += 1
            if j >= len(A)-1:
                break

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
import numpy as np

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

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

for i in range(M):
    A[np.argmax(A)] = discount(A[np.argmax(A)])

print(np.sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

print(sum(np_A))

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

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

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


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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def main():
  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))
main()

Submission status: Time Limit Exceeded

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

for i in range(M):
    mx = max(A)
    if mx == 0:
        break
    idx = A.index(mx)
    A[idx] //= 2
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)
    if l[i] <= 0:
        l.remove(l[i])
        if len(l) == 0:
            break
        
print(sum(l))

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:
import math
n, m = map(int, input().split())
a = list(map(int,input().split()))

for i in range(m):
    s = a.index(max(a))
    k = int(max(a))
    a[s] = math.floor(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):
    max_idx = a.index(max(a))
    a[max_idx] = a[max_idx] // 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

s = input().split()
N = int(s[0])
M = int(s[1])
A = np.array(list(map(int, input().split())))

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

inputData = input().split()
N, M = [int(x) for x in inputData]
inputData = input().split()
A = np.array([float(x) for x in inputData])

for i in range(M):
    index = np.argmax(A)
    A[index] = A[index] / 2.0
A = np.floor(A)
print(int(A.sum()))

Submission status: Time Limit Exceeded

Solution code:
str = input()

split = str.split(" ")

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

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

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

As=sorted(A, reverse=True)

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

print(sum(As))

Submission status: Time Limit Exceeded

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

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

tmp = 0
for m in range(1, M + 1):
    div = A[-m]
    tmp += div
    div = div // 2
    bisect.insort(A, div)
    #print(A)
print(sum(A) - tmp)

Submission status: Time Limit Exceeded

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


for j in range(M):
    max=0
    max_idx=0
    for i in range(len(L)):
        if(max<L[i]):
            max = L[i]
            max_idx = i

    L[max_idx] = L[max_idx]//2
    
print(sum(L))

Submission status: Time Limit Exceeded

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

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

print(sum(cost))

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



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

print(np.sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

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

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
items = list(map(int, input().split()))
items.sort(reverse=True)
for _ in range(M):
	items[0] //= 2
	items.sort(reverse=True)
print(sum(items))

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)
    x = prices.index(max(prices))
    prices[x] = int(prices[x] / 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(reverse=True)
#print(A)

B=A[0:max(N,M)]

for i in range(M):
    idx = B.index(max(B))

    B[idx] = int(B[idx] / 2.0)
#    A.sort(reverse=True)

ans = 0
for i in range(N):
    if i < len(B):
        ans+=B[i]
    else:
        ans += A[i]

print(ans)

Submission status: Time Limit Exceeded

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

print(sum(A))

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


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

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

Submission status: Time Limit Exceeded

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

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)
ls2=[0]
ls.append(-1)
index=0
for i in range(M):
  x=ls2[-1]
  if x<ls[index]:
    ls2.append(ls[index])
    index+=1
  ls2[-1]//=2
  ls2.sort()
#  print(ls2,index,ls)
print(sum(ls2)+sum(ls[index:])+1)

Submission status: Time Limit Exceeded

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


for i in range(0,M):
    max_value = max(A)
    max_index = A.index(max_value)

    A[max_index] = (A[max_index] // 2)


print (sum(A))

Submission status: Time Limit Exceeded

Solution code:

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

a.sort()

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

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

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:
import bisect
import math
import sys
imput = sys.stdin

N, M = [int(item) for item in input().rstrip().split()]
As = sorted([float(item) for item in input().rstrip().split()])
for i in range(M):
    _t = As.pop()
    bisect.insort_right(As, _t/2)
    
_sum = sum([math.floor(item) for item in As])
print(_sum)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

sorted_an = sorted(an)
sorted_an.reverse()

discounts = []
for a in sorted_an:
    row = [] # 差が入る
    prev_discounted_price = a
    for i in range(1, m + 1):
        discounted_price = a // (2 ** i)
        row.append(discounted_price - prev_discounted_price)
        prev_discounted_price = discounted_price
    discounts.append(row)

flatten = np.array(discounts).flatten()
reversed_discounts = np.sort(flatten)
total_discounts = reversed_discounts[:m]

print(sum(an) + np.sum(total_discounts))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

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

for i in range(M):
    max_ind = A.argmax()
    A[max_ind] = A[max_ind] // 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] = int(A[0] / 2)

else:
    for i in range(M):
        A[0] = int(A[0] / 2)
        if A[0] < A[1]:
            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()))
a.sort(reverse=True)
for j in range(m):
  if len(a) != 1:
    if a[0] >= a[1]:
      a[0] //= 2
    else:
      a[1] //= 2
      a.sort(reverse=True)
  else:
    a[0] //= 2
print(sum(a))

Submission status: Time Limit Exceeded

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

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


for _ in range(M):
    A[numpy.argmax(A)] //= 2

print(sum(A))

Submission status: Time Limit Exceeded

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

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

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
A = sorted(map(int, input().split()))[::-1]

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

Submission status: Time Limit Exceeded

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

for _ in range(M):
    i = A.index(max(A))
    a=A[i]>>1
    A[i]=a

print(sum(A))

Submission status: Time Limit Exceeded

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

A = sorted(A)
for i in range(M):
    A[N-1] =  A[N-1]/2
    x = N-1
    while A[x-1] > A[x]:
        temp = A[x-1]
        A[x-1] = A[x]
        A[x] = temp
        x -= 1
        if x == 0:
            break
ans = 0
for i in (A):
    ans+=int(i)
print(ans)

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

Submission status: Time Limit Exceeded

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

price_list = [int(i) for i in price_list]
 
for m in range(M):
  max_num = price_list.index(max(price_list))
  price_list[max_num] = int(price_list[max_num] / 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):
    Amax = a.index(max(a))
    a[Amax] = a[Amax] // 2
    if sum(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()))
dp = [[0 for _ in range(M+1)] for j in range(N+1)]
for i in range(0, N):
  for j in range(0, M+1):
    dp[i+1][j] = min([dp[i][j-k] + A[i]//2**k for k in range(0, M+1) if j-k>=0])
print(dp[N][M])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math
import bisect

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 = A.pop(-1)
    bisect.insort(A, a)
  A[N - 1] /= 2.0
amount = 0
for a in A:
  amount += math.floor(a)
print(amount)

Submission status: Time Limit Exceeded

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

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():
    _, M = MAP()
    A = LIST()
    A = sorted(A)

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

    print(sum(A))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

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

A = deque(A)
A = sorted(A)

for _ in range(M):
    temp = A.pop() // 2
    A.append(temp)
    A = sorted(A)

print(sum(A))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(n[1]):
    ma=max(a)
    a.remove(ma)
    a.append(int(ma/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()))

a.sort(reverse=True)

for i in range(m):
    a[0] /= 2
    tmp = a.pop(0)
    j = 0
    for j in range(n - 1):
        if tmp > a[j]:
            break
    a.insert(j, tmp)

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

Submission status: Time Limit Exceeded

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

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

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

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

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

print(sum(A))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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


print(int(sum(As)))

Submission status: Time Limit Exceeded

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

a = sorted(l, reverse=True)

idx = 0
for i in range(m):
    a[idx] = a[idx]//2
    max_val = max(a)
    if (max_val == 0):
        print(0)
        exit()
    idx = a.index(max_val)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
# sys.stdin.readline()
import sys
input = sys.stdin.readline
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 = max(A) // 2
    j = A.index(max(A))
    A[j] = a


print(sum(A))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = (int(n) for n in input().split())
A = list((int(a) for a in input().split()))
A.sort()
A.reverse()
while(M>0):
    A[0] = int(A[0]/2)
    if len(A)>1 and A[0]<A[1]:
        A.sort()
        A.reverse()
    M-=1
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = sorted(a,reverse=True)
ans = 0
if n == 1:
    b[0] //= 2**m
else:
    while m > 0:
        b[0] //= 2
        m -= 1
        if b [0] < b[1]:
            b.sort(reverse=True)
for i in range(n):
    ans += b[i]
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
 
N,M = map(int, input().split())
Ap = input().split()
A = [0]*N
for i in range(N):
    A[i] = int(Ap[i])
A.sort()

for i in range(M):
    x = A[-1]
    x //= 2
    A = A[:-1]
    A.insert(bisect_left(A, x), x)
 
print(sum(A))

Submission status: Time Limit Exceeded

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

TMP=input().split()
A={}
for i in range(0, N):
  A[str(i)]=int(TMP[i])

for i in range(0, M):
  #index = A.index(max(A))
  index = max(A, key=A.get)
  A[str(index)] = int(A[str(index)]/2)

print (sum(A.values()))

Submission status: Time Limit Exceeded

Solution code:
#n:shinamono no kazu
#m:waribiki maisuu

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

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

for _ in range(m):
  maxA=max(a)
  a.remove(maxA)
  a.append(maxA/2)
#print(a)
result=0
for item in a:
  result+=item//1
  
print(int(result))

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 = -1
		smaller = N-1
		target = A.pop(0)
		while larger-smaller!=-1:
			ind = int((larger+smaller)/2)
			if target>A[ind]:
				smaller = ind
			else:
				larger = ind

		A.insert(smaller,target)
		# print(A)

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

top = 0
for i in range(M):
  for j in range(len(A)):
    if A[j] > A[top]:
      top = j
  A[top] = A[top] // 2

print(sum(A))

Submission status: Time Limit Exceeded

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

for m in range(M):
  mx_A = max(A)
  A.remove(mx_A)
  A.append(mx_A // 2)

ans = sum(A)
print(ans)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import heapq

N,M = map(int,input().split())
AList = list(map(int,input().split()))
A2List = list(map(lambda x:x*(-1), AList))
heapq.heapify(A2List)

for i in range(M):
    x = heapq.heappop(A2List)
    x2 = (-x) // 2
    heapq.heappush(A2List,-x2)
    #print(A2List)
    if sum(A2List) == 0:
        break

print(-sum(A2List))

Submission status: Time Limit Exceeded

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

A=[""]*N

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

for i in range(M):
    for j in range(N):
        if A[j]==max(A):
            A[j]=math.floor(A[j]/2)
            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 _ in range(M):
    a[a.argmax()] //= 2
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
a=input().split(' ')
b=input().split(' ')
m=int(a[1])
b=[int(x) for x in b]
b.sort(reverse=True)
while m>0:
    b[0]=b[0]/2
    b.sort(reverse=True)
    m-=1
print(str(sum([int(x) for x in b])))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
nums = list(map(int, input().split()))
tik = 0
while tik < M:
    nums.sort(reverse=True)
    num = nums[0] // 2
    for i in range(N):
        if tik == M:
            break
        if nums[i] > num:
            nums[i] = nums[i] // 2
            tik += 1
        else:
            break
print(sum(nums))

Submission status: Time Limit Exceeded

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

while True:
    if m <= 0:
        break
    a[0] = a[0] // 2
    a = list(reversed(sorted(a)))
    m -= 1

ans = sum(a)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
N, M = [int(x) for x in input().split(" ")]
As = [int(x) for x in input().split(" ")]
As.sort()
for i in range(M):
    As[-1] //= 2
    As.sort()
sum = 0
for num in As:
    sum += num
print(sum)

Submission status: Time Limit Exceeded

Solution code:
master = list(map(int, input().split()))
merchandises = list(map(int, input().split()))
merchandises.sort(reverse = True)

for dc in range(master[1]):
    merchandises[0] = int(merchandises[0] / 2)
    merchandises.sort(reverse=True)

fullPrice = 0
for p in merchandises:
    fullPrice += p

print(fullPrice)

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):
    max_i = np.argmax(x)
    if x[max_i] == 0:
        break
    x[max_i] = np.trunc(x[max_i]/2.0)
print(np.sum(x))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys

input = sys.stdin.readline

N,M = [int(a) for a in input().split()]
A = np.array([int(a) for a in input().split()])
#m_count = np.zeros(N, dtype=int)

for i in range(M):
    max_idx = np.argmax(A)
    #m_count[max_idx] += 1
    A[max_idx] /= 2

res = [int(a) for a in A]

print(sum(res))

Submission status: Time Limit Exceeded

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

A = input().split()

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

for _ in range(M):
    i = 0
    for _ in A:
        B[int(i)] = (int(A[int(i)]) - int(int(A[int(i)])/2))
        C[int(i)] = int(int(A[int(i)])/2)
        i += 1
    num = B.index(max(B))
    A[num] = C[num]

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

print(result)

Submission status: Time Limit Exceeded

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

for i in range(m):
  b = a[-1]
  a.remove(b)
  b = int(b/2)
  bisect.insort(a,b)
  
print(sum(a))

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

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

print(sum(A))