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 bisect

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

b = []
for ai in a:
    bisect.insort(b,ai )
# print(b)

for i in range(m):
    tmp = b.pop()//2
    bisect.insort(b, tmp)
    # print(b)

print(sum(b))

Submission status: Time Limit Exceeded

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

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

for _ in range(m):
    tmp = max(a)
    a.remove(tmp)
    a.append(tmp//2)
print(sum(a))

Submission status: Time Limit Exceeded

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

for ii in range(m):
    ind = a.index(max(a))
    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())
A = sorted(list(map(int, input().split())), reverse=True)

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline

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



if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
A=list(map(int, input().split()))
for x in range(0,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())

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

for i in range(m):
    i = a_list.argmax()
    a_list[i] = a_list[i] // 2

print(sum(a_list))

Submission status: Time Limit Exceeded

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

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

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):
  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):
    tmp = max(A)
    A.remove(tmp)
    A.append(tmp//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()]

for i in range(m):
    down = max(a)
    a.remove(down)
    a.append(down//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:
import math
n, m = map(int, input().split())
a = [int(i) for i in input().split()]
b = [[math.log(aa, 2), i] for i, aa in enumerate(a)]

for i in range(m):
    a[max(b)[1]] = int((max(a) / 2) // 1)
    b[max(b)[1]][0] -= 1
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import bisect as bi


def solve(N: int, M: int, A: "List[int]"):
    A.sort()
    for _ in range(M):
        Max = A.pop()
        bi.insort(A, Max//2)
    print(sum(A))


# 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(' ')))
a.sort()
for i in range(m):
    a[-1] = a[-1] // 2
    a.sort()
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

for i in range(m):
    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 _ in range(M):
    A[A.index(max(A))] = max(A) // 2
print(str(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):
    max=A[0]
    imax=0
    for i in range(N):
        if A[i]>max:
            max=A[i]
            imax=i
    A[imax]=int(A[imax]//2)
print(sum(A))

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(reverse=True)
#print(As)
for i in range(M):
    As[0] = int(As[0] / 2)
    As.sort(reverse=True)
sum = 0
for num in As:
    sum += num
print(sum)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
X = []
C = [0] * N
for j in range(30):
    for i in range(N):
        X.append((i, j, A[i]>>j))
X = sorted(X, key = lambda x: -x[2])
ans = sum(A)
for i, j, x in X[:M]:
    if C[i] == j:
        C[i] += 1
        ans -= x - x//2
print(ans)

Submission status: Time Limit Exceeded

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



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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

#input = raw_input
N, M = map(int, input().split(" "))
prices = list(map(int, input().split(" ")))

prices = np.asarray(prices)

for i in range(M):
    #max_p = max(prices) 
    max_i = prices.argmax() 
    #max_i = prices.index(max_p)
    prices[max_i] //=  2 

#out = sum(prices)
out = prices.sum()
print(out)

Submission status: Time Limit Exceeded

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

for i in range(M):
    A[0] //= 2
    A = sorted(A,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 = sorted(a)

if len(a) != 1:
  while m != 0:
    d = int(a[n-1] / a[n-2])
    if m < d:
      d = m
    a[n-1] /= 2 ** d
    m -= d
    a = sorted(a)
else:
  a[0] /= 2 ** m

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

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
a=[int(x) for x in input().split()]
s=0
for c in range(m):
    a.sort()
    b=a[n-1]
    a.remove(b)
    a.append(int(b/2))
for c in range(n):
    s=s+a[c]
print(s)

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):
    value = a[-1] // 2
    del a[-1]
    bisect.insort(a, value)

print(sum(a))

Submission status: Time Limit Exceeded

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

As = sorted(As,reverse=True)
M_allocation = [0 for _ in range(N)]


argmax = 0
for i in range(M):
    As[argmax] = As[argmax]//2
    argmax =  np.argmax(As)
print(sum(As))

Submission status: Time Limit Exceeded

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]*=-1
import heapq
heapq.heapify(a)
for i in range(m):
    # print(a)
    tmp=heapq.heappop(a)
    tmp=tmp*-1
    tmp=tmp//2
    tmp*=-1
    heapq.heappush(a,tmp)
    heapq.heapify(a)
print(sum(a)*-1)

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:
n1, n2 = [int(i) for i in input().split()]
n3 = [int(i) for i in input().split()]

n3.sort()
for i1 in range(n2):
    n3[n1 - 1] = n3[n1 - 1] // 2
    n3.sort()

r1 = 0
for i2 in range(n1):
    r1 += n3[i2]

print(r1)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
ps = list(map(int, input().split()))
s = sum(ps)
ls = []
for p in ps:
    prev = p
    while p > 0:
        p //= 2
        ls.append(prev - p)
        prev = p
ls.sort(reverse=True)
print(s - sum(ls[:m]))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

print(sum(A_list))

Submission status: Time Limit Exceeded

Solution code:
import bisect
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
for _ in range(m):
  m=A.pop()//2
  bisect.insort_left(A,m)
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[-1] //= 2

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import bisect

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
for i in range(M):
    x = A.pop()
    bisect.insort(A, x/2)
print(sum(map(int, A)))

Submission status: Time Limit Exceeded

Solution code:
N,M=map(int,input().split())
*A,=map(int,input().split())
l=[]
for a in A:
    k=a
    while k>=1:
        l+=[k-k//2]
        k=k//2
print(sum(A)-sum(sorted(l)[-M:]))

Submission status: Time Limit Exceeded

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

while(m>0):
    a[0]=a[0]//2
    m-=1
    a=sorted(a,reverse=True)
print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import math
import collections
import itertools
import sys
import bisect
from heapq import heappop,heappush
sys.setrecursionlimit(10**6)
def MAP(): return list(map(int,input().split()))
def INT(): return int(input())
def FLOAT(): return float(input())
MOD = 10**9+7

n,m = MAP()
a = MAP()
a.sort()

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

print(sum(a))

Submission status: Time Limit Exceeded

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

for _ in range(0, m):
	xs[-1] /= 2
	xs.sort()

print(sum(int(x) for x in xs))

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_ind = A.index(max(A))
    
    max_value = A[max_ind]
    
    A[max_ind] = max_value // 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 _ in range(M):
  a = A.pop(-1) // 2
  A.insert(bisect.bisect_left(A, a), a)

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M = map(int, input().split())
        A = list(map(int, input().split()))

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

        print(sum(A))


# Run main
if __name__ == '__main__':
    AtCoder().main()

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

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

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

b = sum([math.floor(i) for i in a])
print(b)

Submission status: Time Limit Exceeded

Solution code:
#import numpy as np

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

prices = list(map(int, input().split(" ")))
for i in range(M):
    max_p = max(prices) 
    max_i = prices.index(max_p)
    prices[max_i] //=  2 

out = sum(prices)
print(out)

Submission status: Time Limit Exceeded

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


main()

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(-1)
    tgt //= 2
    bisect.insort(a, tgt)

print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

a.sort()

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

print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(m):
  a=sorted(a)
  a[n-1]=a[n-1]/2
  
ans=0
for j in range(n):
  ans=ans+int(a[j])
  
print(ans)

Submission status: Time Limit Exceeded

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

    sort_A = sorted(A, reverse=True)

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

    print(sum(sort_A))

main()

Submission status: Time Limit Exceeded

Solution code:
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
from copy import deepcopy as dp
B = dp(A)
for m in range(M):
    B[B.index(max(B))] = B[B.index(max(B))] // 2
print(sum(B))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect

setrecursionlimit(1000000)


def main():
	n,m = map(int,input().split())
	a = list(map(int,input().split()))
	a.sort()
	for i in range(m):
		mx = a.pop(-1)
		insert_index = bisect.bisect_left(a,mx//2)
		a.insert(insert_index,mx//2)
	print(sum(a))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

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 = sorted(A,reverse=True)
print(sum(A))

Submission status: Time Limit Exceeded

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

for i in range(m):
    a[-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 = list(map(int,input().split()))
A.sort()
for i in range(M):
    x = A.pop(-1) // 2
    insert_index = bisect.bisect_left(A,x)
    A.insert(insert_index,x)
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()]
for i in range(M):
  A[A.index(max(A))] = A[A.index(max(A))]//2
print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import math
n, m = map(int, input().split())
a = list(float(x) for x in input().split())
a.sort(reverse=True)
for i in range(m):
    a[0] = a[0]/2
    for j in range(n-1):
        if a[j] < a[j+1]:
            a[j], a[j+1] = a[j+1], a[j]
        else:
            break
ans = 0
for i in range(n):
    ans += math.floor(a[i])
print(ans)

Submission status: Time Limit Exceeded

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

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

a.sort(reverse=True)

for i in range(m):
    a[0] //= 2
    if len(a) > 1 and a[0] < a[1]:
        a.sort(reverse=True)

print(sum(a))

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import numpy as np
 
n,m = [int(x) for x in stdin.readline().rstrip().split()]
a_lst = np.array([int(x) for x in stdin.readline().rstrip().split()])

for i in range(m):
  a_lst[np.argmax(a_lst)] = a_lst[np.argmax(a_lst)] // 2
  
print(np.sum(a_lst))

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


a = [int(ai) for ai in a]
ret = sum(a)

print(ret)

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
a = inpl()
a.sort()
for i in range(m):
    a[-1] /= 2
    a.sort()
for i in range(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 _ in range(M):
    A.sort(reverse=True)
    A[0]=int(A[0]//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)


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

print(sum(A))

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):
    p = A.pop()
    p //= 2
    index = bisect.bisect_left(A, p)
    A.insert(index, p)
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]=a[n-1]//2

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

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
item=list(map(int,input().split()))
while 1:
    if m==0:break
    else:
        add=item.index(max(item))
        item[add]=item[add]//2
        m -=1

print(sum(item))

Submission status: Time Limit Exceeded

Solution code:
from heapq import *
n,m=map(int,input().split())
a=list(map(int,input().split()))
q=[]
for i in a:
    heappush(q,[-i,i,0])
for i in range(m):
    s,t,u=heappop(q)
    u+=1
    heappush(q,[-(t//(2**u)),t,u])
print(sum(-q[i][0]for i in range(n)))

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import bisect 
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(m):
    a[-1]=a[-1]//2
    a.sort()
print(sum(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(M):
  tmp = max(As)
  As.remove(tmp)
  tmp = tmp // 2
  As.append(tmp)
  
print(sum(As))

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
import sys, random
mod = 1000000007
def get_array(): return list(map(int, sys.stdin.readline().split()))
def get_ints(): return map(int, sys.stdin.readline().split())
def input(): return sys.stdin.readline()
def print_array(a): print(" ".join(map(str, a)))
def main():
        n, m = get_ints()
        a = get_array()
        while m > 0:
                x = max(a)
                a[a.index(x)] //= 2
                m -= 1
        print(sum(a))
if __name__ == "__main__":
        main()

Submission status: Time Limit Exceeded

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

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

print(sum(A))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
import sys
# import collections

# import bisect
# import math
import numpy as np
# from fractions import gcd

"""Template"""


class IP:
    """
    入力を取得するクラス
    """

    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: int
        """
        return int(self.input())

    def S(self):
        """
        1文字の取得(str
        :return: str
        """
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]

    def SILS(self, n):
        """
        Some Int LineS
        横に複数、縦にも複数
        :param n: 行数
        :return: list
        """
        return [self.IL() for _ in range(n)]

    def SSLS(self, n):
        """
        Some String LineS
        :param n: 行数
        :return: list
        """
        return [self.SL() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def S(self, s, r=0, m=-1):
        """
        ソート関係行います。色々な設定あります。
        :param s: 元となるリスト
        :param r: reversするかどうか 0=False 1=True
        :param m: （2次元配列）何番目のインデックスのソートなのか
        :return: None
        """
        r = bool(r)
        if m == -1:
            s.sort(reverse=r)
        else:
            s.sort(reverse=r, key=lambda x: x[m])

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x // y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)

    def gcd(self, x, y):
        if y == 0:
            return x
        else:
            return self.gcd(y, x % y)

    def lcm(self, x, y):
        return (x * y) // self.gcd(x, y)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    n, m = ip.IL()
    a = np.array(ip.IL())
    for _ in range(m):
        a[np.argmax(a)] //= 2
    print(np.sum(a))


main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import math

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

a = sorted(a)

for i in range(m):
    p = a.pop()
    p = math.floor(p/2)
    a.append(p)
    a = sorted(a)

print(sum(a))

Submission status: Time Limit Exceeded

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