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: Runtime Error

Solution code:
import sys
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(N):
       AA[i] = A[i] * (-1))
    heapq.heapify(AA)

    for i in range(M):
        maxaa=-1 * heapq.heappop(AA)
        if max(A) == 0:
            print("0")
            exit()
        heapq.heappush(AA,  maxaa // 2 * (-1))
    print(sum(AA) * (-1))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import heapq
n ,m = map(int,input().split())
arr =list(map(int,input().split()))
for _ in range(m):
  j = heapq.nlargest(1,arr)//2
  arr.remove(max(arr))
  arr.append(j)
print(sum(arr))

Submission status: Runtime Error

Solution code:
import bisect
import math

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

a.sort(reverse=True)

ans=[math.ceil(-a[0]/2)]
num = 0
now = 1

if n == 1:
    print(a[0] // 2**m)
    exit()
    
for i in range(m-1):
    #print(ans[0],a[now],now,ans)
    if now >= n:
        tmp = math.ceil(ans[0] / 2)
        idx = bisect.bisect_right(ans,tmp)
        #print(ans,idx,tmp)
        ans.insert(idx,tmp)
        del ans[0]
    if ans[0] <= -a[now]:
        tmp = math.ceil(ans[0] / 2)
        idx = bisect.bisect_right(ans,tmp)
        #print(ans,idx,tmp)
        ans.insert(idx,tmp)
        del ans[0]
    else:
        ans.append(math.ceil(-a[now]/2))
        now += 1
print(ans,ans,ans,ans)
exit()
        
if len(ans) == len(a):
    print(-sum(ans))
    exit()
        
print(-sum(ans)+sum(a[len(ans):]))
exit()
for i in range(1,n):
 if num >= m:
   break
 if -a[i]>=ans[-1]: #i番目の要素がansの最小値以下であればansに付け加える
   ans.append(-a[i]//2)
   num+=1
 else:
   pos=bisect.bisect_right(ans,-a[i]) #i番目の要素以下の値で、最も大きい値の位置を求める
   ans[pos]=-a[i] #その位置の値をi番目の要素と置き換える

print(ans)
print(-sum(ans))
exit()

a = [-a]
print(a)
exit()

tmp = a[0] // 2

del a[0]

idx = bisect.bisect_right(a,tmp)
a.insert(idx,tmp)
print(a,idx)
exit()

if a[0] >= a[1]:
    a[0] = a[0] // 2
else:
    a[1] = a[1] // 2
    
print(a)

Submission status: Runtime Error

Solution code:
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
#print(a)
if n == 1:
    for _ in range(m):
        a[0] //= 2
else:
    for _ in range(m):
        a[0]//=2
        b = a[0]
        a.pop(0)
        for i in range(m-1):
            if a[i] > b:
                a.insert(i, b)

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

Submission status: Runtime Error

Solution code:
from heapq import heappush, heappop
N, M = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))

queue = []
for a in A:
    heappush(queue, -a)

for _ in range(M):
    heappush(queue, -(-heappop(queue) // 2))
print(-sum(queue))

Submission status: Runtime Error

Solution code:
import math
import heapq

N, M = list(map(int, input().split()))
A = list(map(lambda a: -int(a), input().split()))
A.sort()
heapq.heapify(A)

for i in range(M):
  a = heapq.heappop(A)
  a =/ 2.0
  heapq.heappush(A, a)

amount = 0
for a in A:
  amount += math.floor(-a)
print(amount)

Submission status: Runtime Error

Solution code:
import bisect

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

cnt = 1
while cnt <= M:
    x = bisect.bisect_right(A, A[-1]/2)
    for i in range(x + 1):
        A[-i -1] /= 2
        cnt += 1
        if cnt > M:
            break
    A.sort()

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

Submission status: Runtime Error

Solution code:
N, M = map(int,input().split())
prices = list(map(int,input().split()))
prices.sort(reverse=True)
for _ in range(M):
    if prices[0] > prices[1]:
        prices[0] //= 2
    else:
        prices[1] //= 2
print(sum(prices))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
sn,sm = input().split(" ")
n = int(sn)
m = int(sm)
a = input().split(" ")
l = len(sa)

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
b=sorted(a)


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

print(sum(b))

Submission status: Runtime Error

Solution code:
import heapq

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

A *= -1

heapq.heapify(A)

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

print(-sum(A))

Submission status: Runtime Error

Solution code:
from numpy import array, sum, argmax
import heapq

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

A *= -1

heapq.heapify(A)

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

print(-sum(A))

Submission status: Runtime Error

Solution code:
import bisect

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

cnt = 1
while cnt <= M:
    x = bisect.bisect_right(A, A[-1]/2)
    for i in range(x + 1):
        A[-i -1] /= 2
        cnt += 1
        if cnt > M:
            break

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

Submission status: Runtime Error

Solution code:
n = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
M=n[1]
def kyoukai(lis,m):
    s=0
    for i in range(n):
        s+=math.log2(lis[i])
        if s>=n[1]*2:
            boundary=i+1
            break
    return boundary
d=kyoukai(a,M)
for i in range(d):
    a[i]=int(a[i]/2)
    if M-d>0:
        M-=d
        d=kyoukai(a,M)
    else:
        break
print(sum(a))

Submission status: Runtime Error

Solution code:
import bisect
import math

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

a.sort(reverse=True)

ans=[math.ceil(-a[0]/2)]
num = 0
now = 1

if n == 1:
    print(a[0] // 2**m)
    exit()
    
for i in range(m-1):
    #print(ans[0],a[now],now,ans)
    if ans[0] <= -a[now]:
        tmp = math.ceil(ans[0] / 2)
        idx = bisect.bisect_right(ans,tmp)
        #print(ans,idx,tmp)
        ans.insert(idx,tmp)
        del ans[0]
    else:
        ans.append(math.ceil(-a[now]/2))
        now += 1
#print(ans,ans,ans,ans)
        
if len(ans) == len(a):
    print(-sum(ans))
    exit()
        
print(-sum(ans)+sum(a[len(ans):]))
exit()
for i in range(1,n):
 if num >= m:
   break
 if -a[i]>=ans[-1]: #i番目の要素がansの最小値以下であればansに付け加える
   ans.append(-a[i]//2)
   num+=1
 else:
   pos=bisect.bisect_right(ans,-a[i]) #i番目の要素以下の値で、最も大きい値の位置を求める
   ans[pos]=-a[i] #その位置の値をi番目の要素と置き換える

print(ans)
print(-sum(ans))
exit()

a = [-a]
print(a)
exit()

tmp = a[0] // 2

del a[0]

idx = bisect.bisect_right(a,tmp)
a.insert(idx,tmp)
print(a,idx)
exit()

if a[0] >= a[1]:
    a[0] = a[0] // 2
else:
    a[1] = a[1] // 2
    
print(a)

Submission status: Runtime Error

Solution code:
from heapq import heappop,heappush,heapify
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
a_minus = [-x for x in a]
heapq.heapify(a_minus)

pop = lambda: -heappop(a_minus)
push = lambda x: heappush(a_minus,-x)

for _ in range(m):
    x = pop()
    push(x//2)

print(-sum(a_minus))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import bisect

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

cnt = 1
while cnt <= M:
    x = bisect.bisect(A, A[-1]/2)
    for i in range(x + 1):
        A[-i -1] /= 2
        cnt += 1
        if cnt > M:
            break

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

Submission status: Runtime Error

Solution code:
import bisect

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

A = sorted(list(map(int, input().split())), reverse=True)
for _ in range(M):
    B = int(int(A.pop(0))/2)
    hantei = True
    for i in range(N):
        if A[i] <= B:
            A.insert(i, B)
            hantei = False
            break
    if hantei:
        A.insert(N-1, B)

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

print(result)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import bisect
import numpy as np

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

a = sorted(a)

for i in range(m):
    a[n-1] = a[n-1] // 2
    temp = a.pop()
    bisect.insort_left(a, temp)
print(sum(a))

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
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)))
list_a.sort(reverse = True)
a_max = list_a[0] // 2
list_a[0] = a_max
count = 1
if m == 1:
    print(sum(list_a))
    sys.exit()
for i in range(m-1):
    if list_a[np.argmax(list_a[0:count])] < list_a[count]:
        #print(list_a[np.argmax(list_a[0:count])],list_a[count])
        list_a[count] = list_a[count] // 2 
        count += 1
    else:
        list_a[np.argmax(list_a[0:count])] = list_a[np.argmax(list_a[0:count])] // 2
        #print(list_a[np.argmax(list_a[0:count])])
print(sum(list_a))
"""
for i in range(m):
    count = 0
    while count == 0:

        for j in range(n):
            
            if list_a[j] > a_max:
                list_a[j] = list_a[j]//2
                a_max = a_max//2
                count = 1 
                print("c=1")
                print(a_max)
                print(list_a)
                break
        if count == 0:
            a_max -= 1
            print("c=0")
    
print(list_a)
"""

Submission status: Runtime Error

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文字に省略
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    _, m, *a = open(0).read().split()
    # print([a[np.argmax(a)] // 2 for _ in range(m)])
    for _ in range(m):
        a[np.argmax(a)] //= 2
    print(np.sum(a))


main()

Submission status: Runtime Error

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文字に省略
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    _, m, *a = open(0).read().split()
    # print([a[np.argmax(a)] // 2 for _ in range(m)])
    for _ in range(m):
        a[np.argmax(a)] //= 2
    print(np.sum(a))


main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(N):
	A[N] = A[N]// 2
	A.sort()

B = sum(A)

print(B)

Submission status: Runtime Error

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

A.sort(reverse=True)

for m in range(M):
    A[0] //= 2
    for n in range(N):
        if A[n] < A[n+1]:
            A[n], A[n+1] = A[n+1], A[n]
        else:
            break

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

Submission status: Runtime Error

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)
        for j in range(M):
            if A[j] < A[j + 1]:
                tmp = A[j + 1]
                A[j + 1] = A[j]
                A[j] = tmp
            else:
                break

print(sum(A))

Submission status: Runtime Error

Solution code:
from collections import deque
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))
queue=deque(A)
for i in range(M):
    queue.append([max(queue)//2])
    queue.remove(max(queue))
print(sum(queue))

Submission status: Runtime Error

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

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

print(sum(modey))

Submission status: Runtime Error

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

import numpy as np

def main():
    n, m_num = map(int, input().split())
    a_list = np.array([int(i) for i in input().split()])
    a_list.sort()

    def func(a, m):
        temp = a[-1]//2
        a[-1] = temp
        a.sort()
        ind = np.where(a==temp)[0][0]
        m -= 1
        if m == 0:
            print(np.sum(a))
        elif n - ind < m:
            a[a>=temp] = a[a>=temp]//2
            a.sort()
            m = m - (n-ind)
            if m>0:
                func(a, m)
            else:
                print(np.sum(a))
        else:
            a[-m:] = a[-m:]//2
            print(np.sum(a))

    func(a_list, m_num)

main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
while M>0:
    d = max(A[0]//A[1], 1)
    A[0] = A[0]//2**d
    M -= d
    A = sorted(A, reverse=True)
    # print(A, M)

print(sum(A))

Submission status: Runtime Error

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)))
list_a.sort(reverse = True)
a_max = list_a[0] // 2
list_a[0] = a_max
count = 2
for i in range(m-1):
    if list_a[np.argmax(list_a[0:count])] < list_a[count]:
        #print(list_a[np.argmax(list_a[0:count])],list_a[count])
        list_a[count] = list_a[count] // 2 
        count += 1
    else:
        list_a[np.argmax(list_a[0:count])] = list_a[np.argmax(list_a[0:count])] // 2
        #print(list_a[np.argmax(list_a[0:count])])
    
print(sum(list_a))
"""
for i in range(m):
    count = 0
    while count == 0:

        for j in range(n):
            
            if list_a[j] > a_max:
                list_a[j] = list_a[j]//2
                a_max = a_max//2
                count = 1 
                print("c=1")
                print(a_max)
                print(list_a)
                break
        if count == 0:
            a_max -= 1
            print("c=0")
    
print(list_a)
"""

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=[int(i) for i in input().split()]
b=sorted()

for i in range(0,m):
    b[0] = b[0] // 2
    if b[0] < b[1]:
        b[0],b[1] = b[1],b[0]
    
print(sum(b))

Submission status: Runtime Error

Solution code:
import numpy as np
n, m = map(int, input().split())
a = [int(i) for i in input().split(" ")]
a = np.sort(a)
b = np.log2(a)
if np.sum(b//1)+n < m:
    print(0)
else:
    t = b.copy()
    c = m
    ind = n-1
    while c>0:
        if b[ind] == b[ind-1]:
            ind -= 1
            if ind == 0:
                for i in range(int(c)):
                    b[b.argmax()] -= 1
                c = 0
                
        if (b[ind] - b[ind-1] + 1)//1*(n-ind) <= c:
            c -= (b[ind] - b[ind-1] + 1)//1*(n-ind)
            b[ind:] -= (b[ind] - b[ind-1] + 1)//1
            ind -= 1
        else:
            for i in range(int(c)):
                b[b.argmax()] -= 1
            c = 0
    tm = [2**int(i) for i in t-b]
    print(int(np.sum(np.array(a, dtype="object")/tm//1)))

Submission status: Runtime Error

Solution code:
import bisect
import math

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

a.sort(reverse=True)

ans=[math.ceil(-a[0]/2)]
num = 0
now = 1

if n == 1:
    print(a[0] // 2**m)
    exit()

for i in range(m-1):
    #print(ans[0],a[now],now,ans)
    if ans[0] <= -a[now]:
        tmp = math.ceil(ans[0] / 2)
        idx = bisect.bisect_right(ans,tmp)
        #print(ans,idx,tmp)
        ans.insert(idx,tmp)
        del ans[0]
    else:
        ans.append(math.ceil(-a[now]/2))
        now += 1
#print(ans,ans,ans,ans)
print(-sum(ans)+sum(a[len(ans):]))
exit()
for i in range(1,n):
 if num >= m:
   break
 if -a[i]>=ans[-1]: #i番目の要素がansの最小値以下であればansに付け加える
   ans.append(-a[i]//2)
   num+=1
 else:
   pos=bisect.bisect_right(ans,-a[i]) #i番目の要素以下の値で、最も大きい値の位置を求める
   ans[pos]=-a[i] #その位置の値をi番目の要素と置き換える

print(ans)
print(-sum(ans))
exit()

a = [-a]
print(a)
exit()

tmp = a[0] // 2

del a[0]

idx = bisect.bisect_right(a,tmp)
a.insert(idx,tmp)
print(a,idx)
exit()

if a[0] >= a[1]:
    a[0] = a[0] // 2
else:
    a[1] = a[1] // 2
    
print(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
if N == 1:
    print("0")
    exit()
A = list(map(int,input().split()))
A.sort(reverse=True)
# print(A)
for i in range(M):
    a = A[0]//2
    A.pop(0)
    for i in range(len(A)):
        if A[i] >= a and A[i+1] <= a :
            A.insert(i+1,a)
            break
    # print(A)
print(sum(A))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import math
num_items, num_tickets = map(int, input().split())
a = []
for _ in range(num_items):
    a.append(list(map(int, input().split())))
for i in range(num_tickets):
    a[a.index(max(a))] = math.floor(a[a.index(max(a))])
print(sum(a))

Submission status: Runtime Error

Solution code:
import numpy as np
N,M=input().split(" ")
N=int(N)
M=int(M)
Alist=input().split(" ")
Alist = [float(A) for A in Alist]
Aarray=np.array(Alist)

for m in range(M):
    i=Aarray.argmax()
    Aarray[i]=Aarray[i]/2
    if Aarray[i]==0:
        break
    # print(Alist)
Aarray_i=Aarray.atype(np.int)

print(np.sum(Aarray))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
ob = input().split(" ")
item = input().spli(" ")
item2 = [int(n) for n in test]
test3 = sorted(test2, reverse=True)
for sp in range(int(ob[1])):
    item[0] = item[0] /2



value = 0
for i in list:
    value = value + int(i)
print(value)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int, input().split())
a=sorted(list(map(int, input().split())),reverse=True)
tot=0
rate=[0]*n
p=[0]*n

for i in range(n-1):
  rate[i]=math.log2(a[i]/a[i+1])
  
cur=0
while m>0:
  if rate[cur]>0:
    p[cur]+=1
    rate[cur]-=1
    m-=1
    if cur>0:
      rate[cur-1]+=1
      cur-=1
  else:
    if cur+1<n
      cur+=1
    else:
      p[cur+1]+=1
      rate[cur+1]-=1
      rate[cur]+=1
      cur-=1
  
for i in range(n):
  tot+=int(a[i]/(2**p[i]))
print(tot)

Submission status: Runtime Error

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

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

print(np.sum(As))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
n, m = map(int, input().split())
a = [int(i) for i in input().split(" ")]
a = np.sort(a)
b = np.log2(a)
if np.sum(b//1)+n < m:
    print(0)
else:
    t = b.copy()
    c = m
    ind = n-1
    while c>0:
        if b[ind] == b[ind-1]:
            ind -= 1
        if (b[ind] - b[ind-1] + 1)//1*(n-ind) <= c:
            c -= (b[ind] - b[ind-1] + 1)//1*(n-ind)
            b[ind:] -= (b[ind] - b[ind-1] + 1)//1
            ind -= 1
        else:
            for i in range(int(c)):
                b[b.argmax()] -= 1
            c = 0
    tm = [2**int(i) for i in t-b]
    print(int(np.sum(np.array(a, dtype="object")/tm//1)))

Submission status: Runtime Error

Solution code:
def sortoriginal(aList):
  i = 1
  while aList[0] <= aList[i]:
    i += 1
  return aList[1:i] + list(aList[0]) + aList[i-1:-1]
  

shoppingListLen, discount = map(int, input().split())
shoppingList = list(map(float, input().split()))
shoppingList.sort(reverse=True)
while shoppingList[0] > 2 * shoppingList[-1]:
  shoppingList[0] /= 2
  shoppingList = sortoriginal(shoppingList)
  discount -= 1
for i in range(discount % shoppingListLen):
  shoppingList[i] = shoppingList / 2
ansList = list(map(lambda x: x / 2**(discount//shoppingListLen), shoppingList))
ans = sum(list(map(int, ansList)))
print(ans)

Submission status: Runtime Error

Solution code:
tmp = list(map(int,(input().split())))
n = tmp[0]
m = tmp[1]

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

while (m > 0): 
  ai.sort(reverse=True)
  for i in range(n-1):
    if ai[i] >= ai[i+1] :
      m -= 1
      ai[i] = ai[i] // 2

for i in range(n):
  sum += ai[i]

# print(ai)
print(sum)