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: Wrong Answer

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

N,M = (int(x) for x in input().rstrip('\n').split())
As = [int(x) for x in input().rstrip('\n').split()]
As = sorted(As,reverse = True)
rest = M
for _ in range(M):
  if rest ==0:
    break
  d = As[0]
  b = d//2 - d//4
  for i in range(N):
    a = As[i]
    if a-a//2<b:
      ad = [x//2 for x in As[:i]]
      if rest > i:
        As = As[i:]
        As.extend(ad)
        rest -= i
        As = sorted(As,reverse = True)
      else:
        ad = [x//2 for x in As[:rest]]
        As = As[rest:]
        As.extend(ad)
        rest = 0
        break
    if i ==N-1:
      if rest > N:
        As = [x//2 for x in As]
        rest -= N
      else:
        ad = [x//2 for x in As[:rest]]
        As = As[rest:]
        As.extend(ad)
        rest = 0
        break
print(sum(As))

Submission status: Wrong Answer

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

N,M = (int(x) for x in input().rstrip('\n').split())
As = [int(x) for x in input().rstrip('\n').split()]
As = sorted(As,reverse = True)
rest = M
for _ in range(M):
  d = As[0]
  b = d//2 - d//4
  check = 0
  for i in range(N):
    a = As[i]
    if a-a//2<b:
      ad = [x//2 for x in As[:i]]
      if rest > i:
        As = As[i:]
        As.extend(ad)
        rest -= i
        As = sorted(As,reverse = True)
      else:
        ad = [x//2 for x in As[:rest]]
        As = As[rest:]
        As.extend(ad)
        check += 1
        break
    if i ==N-1:
      if rest > N:
        As = [x//2 for x in As]
        rest -= N
      else:
        ad = [x//2 for x in As[:rest]]
        As = As[rest:]
        As.extend(ad)
        check += 1
        break
  if check ==1:
    break
print(sum(As))

Submission status: Wrong Answer

Solution code:
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i] = -A[i]
heapq.heapify(A)
for i in range(M):
    trgt = heapq.heappop(A)//2
    heapq.heappush(A,trgt)
print(-sum(A))

Submission status: Wrong Answer

Solution code:
import heapq
import sys
from io import StringIO
import unittest


n, m = map(int, input().split())
a = list(map(lambda x: int(x) * (-1), input().split()))
heapq.heapify(a)

for _ in range(m):
	tmp_min = heapq.heappop(a)
	heapq.heappush(a, (-1) * (-tmp_min // 2))
	print(-sum(a))

Submission status: Wrong Answer

Solution code:
import heapq
import sys
from io import StringIO
import unittest

def resolve():
    n, m = map(int, input().split())
    a = list(map(lambda x: int(x) * (-1), input().split()))
    heapq.heapify(a)

    for _ in range(m):
        tmp_min = heapq.heappop(a)
        heapq.heappush(a, (-1) * (-tmp_min // 2))
    print(-sum(a))

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
import math

# import collections

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

b = [math.log2(_a) for _a in a]

for _m in range(m):
    b[b.index(max(b))] -= 1

c = [int(2 ** _b) for _b in b]
ans = sum(c)
print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
prices = list(map(int, input().split()))
prices.sort()
discounts = prices[:M]
proper = prices[M:]

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

print(sum(discounts)+sum(proper))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = list(map(int, input().split()))
import heapq
a = list(map(lambda x:x*(-1), a))
heapq.heapify(a)
for _ in range(m):
    num = heapq.heappop(a)
    heapq.heappush(a,num//2)
a = list(a)
print(sum(a)*(-1))

Submission status: Wrong Answer

Solution code:
import heapq
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)
for i in range(M):
    max_ = heapq.heappop(A)
    max_ = -max_//2
    heapq.heappush(A, max_)
print(-sum(A))

Submission status: Wrong Answer

Solution code:
import heapq
N, M = map(int, input().split())
A = [-int(i) for i in input().split()]
heapq.heapify(A)
for i in range(M):
    max_ = heapq.heappop(A)
    heapq.heappush(A, max_//2)
print(-sum(A))

Submission status: Wrong Answer

Solution code:
from math import log2
from heapq import heappop, heapify, heappush
def main():
    n, m = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A = [-log2(a) for a in A]
    heapify(A)
    for _ in range(m):
        a = heappop(A)
        a += 1
        heappush(A, a)
    print(sum([int(pow(2, -a)) for a in A if a <= 0]))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import log2
from heapq import heappop, heapify, heappush
def main():
    n, m = list(map(int, input().split()))
    A = list(map(int, input().split()))
    A = [-log2(a) for a in A]
    heapify(A)
    for _ in range(m):
        a = heappop(A)
        a += 1
        heappush(A, a)
    print(sum([int(pow(2, -a)) for a in A]))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a,b=mi()
l=list(mi())
l=list(map(lambda x: x*-1 , l))
heapq.heapify(l)
for i in range(b):
  s=heapq.heappop(l)
  s=(-1)*(-1*s)//2
  heapq.heappush(l,s)
ans=0
for i in range(a):
  d=heapq.heappop(l)
  ans+=(-1)*d
print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heapify, heappop, heappush


N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
if N == 1:
    print(N >> M)
    exit()
heapify(A)
while M > 0:
    a = -heappop(A)
    while M > 0 or a >= -A[0]:
        a >>= 1
        M -= 1
    heappush(A, -a)
print(-sum(A))

Submission status: Wrong Answer

Solution code:
from heapq import heapify, heappop, heappush


N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
if N == 1:
    print(N >> M)
    exit()
heapify(A)
for i in range(M):
    a = -heappop(A)
    while a >= -A[0]:
        a >>= 1
    heappush(A, -a)
print(-sum(A))

Submission status: Wrong Answer

Solution code:

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

#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合
L=list(map(int,input().split()))
L.sort()

Div=[]

S = []

init=2
for i in range(1,31):
    A=init**i
    S.append(A)
lenS=len(S)
for i in range(N):
    for j in range(lenS):
        if L[i]//S[j]==0:
            Div.append(j+1)
            break
        
#print(S)
#print(L)
#print(Div)

tiketsum=(sum(Div))

if tiketsum-M<=0:
    print(0)
    exit()


Revtiket=tiketsum-M
pos=0
TB=[0]*N
while Revtiket>0:
    if Div[pos]>TB[pos]:
        TB[pos]+=1
        Revtiket-=1
    pos+=1
    if pos>=N:
        pos=0
#print(TB)

NDiv=[0]*N
for i in range(N):
    NDiv[i]=Div[i]-TB[i]
    
#print(NDiv)

goukei=0
for i in range(N):
    goukei+=L[i]//(2**NDiv[i])
    
print(goukei)

Submission status: Wrong Answer

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

for _ in range(M):
    x = al.pop()
    bisect.insort(al, x//2)

print(sum(al))

Submission status: Wrong Answer

Solution code:
import heapq

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


while m > 0 :
  m -= 1
  heapq.heapify(a)
  heapq.heappush(a, heapq.heappop(a) // 2)

print(sum(a))

Submission status: Wrong Answer

Solution code:
def main():
    n, m = list(map(int, input().split()))
    t = list(map(int, input().split()))
    while m > 0:
        idx = 0
        t.sort(reverse=True)
        # print(t)
        t[0] //= 2
        m -= 1
        if m != 0:
            if t[0] > t[1]:
                t[0] //= 2
            else:
                t[1] //= 2
            m -= 1

    print(sum(t))

Submission status: Wrong Answer

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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed Jun  3 18:35:23 2020

@author: NEC-PCuser
"""
import heapq

N, M = map(int, input().split())
A = [-int(n) for n in input().split(" ")]

heapq.heapify(A)

for i in range(M):
    most_expensive = -heapq.heappop(A)
    most_expensive //= 2
    heapq.heappush(A, -most_expensive)
    
ans = 0
for j in range(len(A)):
    ans += A[j]

print(ans)

Submission status: Wrong Answer

Solution code:
import heapq
n,m=map(int,input().split())
a=list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(a)

for i in range(m):
    max=heapq.heappop(a)
    heapq.heappush(a,max//2)

print(sum(a)*(-1))

Submission status: Wrong Answer

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

arr.sort()
arr = [math.log2(x) for x in arr]

for _ in range(m):
    q = arr.pop()
    bisect.insort_right(arr, q - 1)

arr = [int(2**x) for x in arr]
    
print(sum(arr))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import heapq
n,m = map(int,input().split())
arr= list(map(lambda x: int(x)*(-1) ,input().split()))
heapq.heapify(arr)
for i in range(m):
    d = heapq.heappop(arr)
    heapq.heappush(arr,-( -d//2))
print(sum(arr)*-1)
print(arr)

Submission status: Wrong Answer

Solution code:
import heapq
n,m = map(int,input().split())
arr= list(map(lambda x: int(x)*(-1) ,input().split()))
heapq.heapify(arr)
for i in range(m):
    d = heapq.heappop(arr)
    heapq.heappush(arr,d//2)
print(sum(arr)*-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
n, m = map(int, input().split())
a = list(map(int, input().split()))
p = [0] * n

arr = np.array(a)

for i in range(m):
    index = np.argmax(arr)
    tar = arr[index]

    p[index] += 1
    arr[index] = math.floor(tar / 2.0)

ans = 0
for i in range(n):
    ans += a[i] / (2 ** p[i])


#ans = math.floor(np.sum(arr))
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import heapq

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m=map(int, readline().rstrip().split())
    arr=list(map(int, readline().rstrip().split()))
    heapq.heapify(arr)
    for i in range(n):
        arr[i]*=-1
    for _ in range(m):
        x=(heapq.heappop(arr)*-1)//2
        heapq.heappush(arr, -x)
    ans=0
    for i in range(n):
        ans+=(arr[i]*-1)
    print(ans)
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(lambda x:int(x)*(-1),input().split()))

from heapq import heappop,heappush

for _ in range(M+1):
    a=heappop(A)*(-1)
    a//=2
    heappush(A,a*(-1))

print(sum(A)*(-1))

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
for _ in range(m):
    a[0] //= 2
    j = 0
    while 2*j+1 < n:
        if 2*j==n:
            if a[j] < a[2*j + 1]:
                a[j],a[2*j+1] = a[2*j+1],a[j]
                break
            else:
                break
        else:
            if a[2*j+1] > a[j]:
                a[j],a[2*j+1] = a[2*j+1],a[j]
            elif a[2*j+2] > a[j]:
                a[j],a[2*j+2] = a[2*j+2],a[j]
            else:
                break
print(sum(a))

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(M):
    A=sorted(A,reverse=True)
    while 1:
        if A[0]==0:
            break
        b=bin(A[0]>>1)
        A[0]=int(b,0)
        if N==1:
            if i==M-1:
                break
        else:
            if i==M-1 or A[0]<A[1]:
                break
        i+=1
print(sum(A))

Submission status: Wrong Answer

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

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

for i in range(m):
    value = a.pop()
    value //= 2
    insert_index = bisect.bisect_left(a, value)

    a.insert(insert_index, value)
print(sum(a))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')


from collections import deque

def heap_create(lst):
    hp = deque([])

    for n, l in enumerate(lst):
        hp.append(l)
        child = n
        parent = (n - 1) // 2
        while parent >= 0:
            if hp[parent] < hp[child]:  # 親が子よりも小さいとき
                hp[child], hp[parent] = hp[parent], hp[child]
            else:
                break
            child = parent
            parent = (n - 1) // 2
    return hp

def heap_pop(hp: deque):
    res = hp.popleft()
    if len(hp) > 0:
        hp.appendleft(hp.pop())
        n = len(hp)
        parent = 0
        while parent < n:
            child_l = parent * 2 + 1
            child_r = parent * 2 + 2

            if child_r < n:
                if hp[child_l] < hp[child_r]:
                    hp[parent], hp[child_r] = hp[child_r], hp[parent]
                    parent = child_r
                else:
                    hp[parent], hp[child_l] = hp[child_l], hp[parent]
                    parent = child_l
            elif child_l < n:
                hp[parent], hp[child_l] = hp[child_l], hp[parent]
                parent = child_l
            else:
                break

    return res

def heap_push(hp: deque, val):
    child = len(hp)
    hp.append(val)
    parent = (child - 1) // 2
    while parent >= 0:
        if hp[parent] < hp[child]:
            hp[parent], hp[child] = hp[child], hp[parent]
        else:
            break
        child = parent
        parent = (child - 1) // 2

def solve():
    n, m = MI()
    A = LI()

    hp = heap_create(A)

    for i in range(m):
        x = heap_pop(hp)
        heap_push(hp, x // 2)

    print(sum(hp))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
from collections import deque
n,m=map(int,input().split())
a=deque(sorted(list(map(int,input().split())),reverse=True))
cnt=deque([0])
for i in range(m):
  if a[0]>=cnt[0]:
    a[0]=a[0]//2
    if i==0:
      cnt.pop()
    cnt.append(a[0])
    a.popleft()
    if len(a)==0:
      a.append(0)
  else:
    cnt[0]=cnt[0]//2 
    if len(cnt)>=2:
      if cnt[0]<=cnt[1]:
        a.append(cnt[0])
        cnt.popleft()
print(sum(a)+sum(cnt))

Submission status: Wrong Answer

Solution code:
n, m = [int(i) for i in input().split()]
prices = sorted([int(i) for i in input().split()], reverse=True)
d = 65536
while(d > 0):
	for i, price in enumerate(prices):
		if price >= d:
			prices[i] = prices[i] // 2
			m -= 1
			if m == 0:
				d = 0
				break
	prices = sorted(prices, reverse=True)
	d /= 2
print (sum(prices))

Submission status: Wrong Answer

Solution code:
import heapq

N, M = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]

hpq = list(map(lambda x: -1 * x, A))
heapq.heapify(hpq)
for i in range(M):
    x = heapq.heappop(hpq)
    heapq.heappush(hpq, x / 2)

sum(map(lambda x: int(-1 * x), hpq))

Submission status: Wrong Answer

Solution code:
# D - Powerful Discount Tickets

import heapq

N, M = map(int, input().split())
A = [int(a) * -1 for a in input().split()]
heapq.heapify(A)
print(A)

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

print(sum(A) * -1)

Submission status: Wrong Answer

Solution code:
# D - Powerful Discount Tickets

import heapq

N, M = map(int, input().split())
A = [int(a) * -1 for a in input().split()]
heapq.heapify(A)

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

print(sum(A) * -1)

Submission status: Wrong Answer

Solution code:
# D - Powerful Discount Tickets

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

for i in range(M):
    price = A.pop()
    A.append(price // 2)
    A.sort()

print(sum(A))

Submission status: Wrong Answer

Solution code:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a) 

for i in range(m):
  max_ = heapq.heappop(a)
  d = max_ // 2
  heapq.heappush(a, d)

print(sum(a))

c = 0
for i in range(len(a)):
  c += heapq.heappop(a)
print(c)

Submission status: Wrong Answer

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

s.append(0)
flag = 0
num = s.pop(-1)//2
for i in range(m - 1):
  if(flag == 1):
    num = s.pop(-1)//2
  else:
    num //= 2
  if(num < s[-1]):
    s.append(num)
    s.sort()
    flag = 1
  else:
    flag = 0

if(flag == 0):
  s.append(num)

print(sum(s))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

l.sort(reverse=True)
res=0

for i in range(n-1):

    while l[i] >= l[i+1] and m>0:
         
         l[i]= l[i] // 2
         m-=1
         l.sort(reverse=True)


print(sum(l))

Submission status: Wrong Answer

Solution code:
'''ika tako
高い順に割引券を多く使いたい。1枚使ってもまだ他より高ければ
2枚、3枚、、、と使えばよいが、ある程度使って他の商品が高くなれば、
そちらに使った方がよい。なので、「今の最高額の商品を、
半額で置き換える」ことを  M  回繰り返す。heapqを使うと1回の操作に  
O(logN)  かかるので、全体で  O(MlogN)  となる。
pop()してpush()してもよいが、replace()を使えば2つの操作を1度に行え、
heap構造を保つための比較処理も1回で済むので定数倍高速。
'''
from heapq import heapify, heapreplace
 
n, m = list(map(int, input().split()))
aaa = [-a for a in map(int, input().split())]
#最大値を取り出したいので、-マイナスを付けている
heapify(aaa)#リストをヒープ(二分木)にする
 
for _ in range(m):
    heapreplace(aaa, aaa[0] // 2)
    #heapreplace(aaa, aaa[0] // 2 + aaa[0] % 2)
    #heappopを行ってからheappushを行う
    
print(-sum(aaa))

Submission status: Wrong Answer

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

for i in range(m):
  a.sort()
  t=int(a[-1]/2)
  a.append(t)
print(sum(a))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
d=[max(a)//2]
a.pop(0)
for i in range(m-1):
  if len(a)>0:
    if a[0]>=d[0]:
      d.append(a[0]//2)
      a.pop(0)
    else:
      d.append(d[0]//2)
      d.pop(0)
  else:
    if len(a)==0:
      a.append(d[0]//2)
    else:
      if d[0]>=a[0]:
        a.append(d[0]//2)
        d.pop(0)
      else:
        a.append(d[0]//2)
        a.pop(0)
print(sum(d)+sum(a))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
d=[max(a)//2]
a.pop(0)
for i in range(m-1):
  if len(a)<=0:
    break
  if a[0]>=d[0]:
    d.append(a[0]//2)
    a.pop(0)
  else:
    d.append(d[0]//2)
    d.pop(0)
print(sum(d)+sum(a))

Submission status: Wrong Answer

Solution code:
import heapq

N,M=input().split()
N,M=int(N),int(M)
A=input().split()
A=[-int(n) for n in A]

heapq.heapify(A)

for i in range(M):
    a=heapq.heappop(A)//2
    heapq.heappush(A,a)
sum=0
for i in range(N):
    sum+=A[i]
print(-sum)

Submission status: Wrong Answer

Solution code:
import heapq
n, m = map(int, input().split())
lst = list(map(int, input().split()))
lst = list(map(lambda x: x*(-1), lst))
heapq.heapify(lst)

for i in range(m):
    tmp_min = heapq.heappop(lst)
    heapq.heappush(lst, tmp_min//2)  # 計算誤差の関係で-1を2回かけてます
print(-sum(lst))

Submission status: Wrong Answer

Solution code:
import heapq as hq

co = list(map(int,input().split()))
A = list(map(int,input().split()))
N = co[0]
M = co[1]
A = list(map(lambda x: x * (-1),A))
hq.heapify(A)
for i in range(M):
    tmp = hq.heappop(A) //2
    hq.heappush(A,tmp)
list(A)

print(sum(A) * (-1))

Submission status: Wrong Answer

Solution code:
import os
import math

def main():
	n,m = map(int, input().split())
	a_list = list(map(int, input().split()))
	a_list.sort(reverse=True)
	
	for i in range(m):
		max_num = a_list[0]
		a_list.append(math.floor(max_num/2))
		a_list.sort(reverse=True)
	print(sum(a_list))
		

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[0]
for i in range(m):
    if b[:-1]<a[:-1]:
        temp=a.pop()
    else:
        temp=b.pop()
    temp=temp//2
    b.append(temp)
    b.sort()

print(sum(a)+sum(b))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[0]
for i in range(m):
    if b[:-1]<a[:-1]:
        temp=a.pop()
    else:
        temp=b.pop()
    temp=temp//2
    b.append(temp)

print(sum(a)+sum(b))

Submission status: Wrong Answer

Solution code:
import heapq

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

A = list(map(int, input().split()))
A = list(map(lambda x:x*(-1), A))

heapq.heapify(A)

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

print(A)
print(sum(A)*(-1))

Submission status: Wrong Answer

Solution code:
import heapq

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

A = list(map(int, input().split()))
A = list(map(lambda x:x*(-1), A))

heapq.heapify(A)

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

print(sum(A)*(-1))

Submission status: Wrong Answer

Solution code:
from collections import deque
N, M = map(int, input().split())

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

d = deque(sorted(A)[::-1])
d_2 = deque([])
a = d.popleft()
d_2.append(a // 2)
M -= 1

while M > 0:
    if len(d) > 0 and d[0] > d_2[-1]:
        a = d.popleft()
        d_2.appendleft(a // 2)
    else:
        d_2[-1] //= 2
    if len(d_2) > 1:
        if d_2[-2] > d_2[-1]:
            tmp = d_2[-2]
            d_2[-2] = d_2[-1] 
            d_2[-1] = tmp
    M -= 1

print(sum(d) + sum(d_2))

Submission status: Wrong Answer

Solution code:
from collections import deque
N, M = map(int, input().split())

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

d = deque(sorted(A)[::-1])
d_2 = deque([])
a = d.popleft()
d_2.append(a // 2)
M -= 1

while M > 0:
    if len(d) > 0 and d[0] > d_2[-1]:
        a = d.popleft()
        d_2.appendleft(a // 2)
    else:
        d_2[-1] //= 2
    M -= 1

print(sum(d) + sum(d_2))

Submission status: Wrong Answer

Solution code:
(n,m) = tuple(map(int,input().split()))
b = list(map(int,input().split()))
a = list(map(lambda x:x*(-1),b))

import heapq
heapq.heapify(a)

temp = 0
for i in range(m):
    temp = heapq.heappop(a)
    heapq.heappush(a,temp/2)

import math
print((-1)*sum(list(map(math.floor,a))))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
sa=sum(a)//n
c=0
if n==1:
    print(a[0]//(2**m))
    exit()
else:
    while True:
        a.sort()
        a1=a[:n//2]
        a2=a[n//2:]
        while True:
            if c==m:
                print(sum(a1)+sum(a2))
                exit()
            if len(a2)==0:
                a=a1
                break
            k=a2.pop(-1)
            while True:
                k=k//2
                c+=1
                if c==m:
                    print(sum(a1)+sum(a2))
                    exit()
                if k<=sa:
                    a1.append(k)
                    break

Submission status: Wrong Answer

Solution code:
import heapq


def main():
    n, m = map(int, input().split())
    a = list(map(lambda x: int(x)*(-1), input().split()))
    heapq.heapify(a)
    for i in range(m):
        item = heapq.heappop(a)
        heapq.heappush(a, item // 2)
    print(-sum(a))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

for i in range(m):
  b=a.pop()
  b//=2
  index=bisect.bisect_left(a,b)
  a.insert(index,b)
  
  
print(sum(a))

Submission status: Wrong Answer

Solution code:
import heapq

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

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

heapq.heapify(a)

num = 0
hq = 1

while num <= M and hq != 0:
    hq = -heapq.heappop(a)//2
    heapq.heappush(a, -hq)
    num += 1

print(-sum(a))

Submission status: Wrong Answer

Solution code:
import heapq

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

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

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)//2
    heapq.heappush(a, -hq)
    num += 1

print(-sum(a))

Submission status: Wrong Answer

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

m_count = 0

while True:
    a_l[0] //= 2
    m_count += 1
    if m_count == m:
        break
    max_price = a_l[0]
    for j in range(1,n):
        if a_l[j] >= max_price:
            a_l[j] //2
            m_count += 1
        else:
            break
    a_l.sort(reverse=True)

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

Submission status: Wrong Answer

Solution code:
import math
N,M=map(int,input().split())
S=input().split()
Snum=[]
for i in range(0,N):
  Snum.append(int(S[i]))
Snum.sort
Snum.reverse
for i in range(0,M):
  j=0
  k=math.floor(Snum[0]/2)
  while k<Snum[j] and j<N-1:
    j=j+1
  for l in range(0,j-1):
    Snum[l]=Snum[l+1]
  Snum[j-1]=math.floor(Snum[0]/2)
print(sum(Snum))

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
def wb(X,Y):
    return int(X/(2**Y))
for i in range(N):
    if M == 0:
        break
    for j in range(1,M+1):
        if A[i]//2 == 0:
            break
        if A[i]//2 < 2**j:
            if j == 1:
                A[i] = wb(A[i],1)
                M -= 1
            if M >= j-1:
                A[i] = wb(A[i],j-1)
                M -= j-1
                break
            else:
                A[i] = wb(A[i],M)
                M = 0
                break
        elif j == M:
            A[i] = wb(A[i], M)
            M = 0
            break
if M > 0:
    for i in range(N):
        while A[i] > 0 and M > 0:
            A[i] = A[i]//2
            M -= 1
print(sum(A))

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
def wb(X,Y):
    return int(X/(2**Y))
for i in range(N):
    if M == 0:
        break
    for j in range(1,M+1):
        if A[i]//2 < 2**j:
            if j == 1:
                A[i] = wb(A[i],1)
                M -= 1
            if M >= j-1:
                A[i] = wb(A[i],j-1)
                M -= j-1
                break
            else:
                A[i] = wb(A[i],M)
                M = 0
                break
        elif j == M:
            A[i] = wb(A[i], M)
            M = 0
            break
if M > 0:
    for i in range(N):
        while A[i] > 0 and M > 0:
            A[i] = A[i]//2
            M -= 1
print(sum(A))

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
print(A)
def wb(X,Y):
    return int(X/(2**Y))
for i in range(N):
    if M == 0:
        break
    for j in range(1,M+1):
        if A[i]//2 < 2**j:
            if j == 1:
                A[i] = wb(A[i],1)
                M -= 1
            if M >= j-1:
                A[i] = wb(A[i],j-1)
                M -= j-1
                break
            else:
                A[i] = wb(A[i],M)
                M = 0
                break
        elif j == M:
            A[i] = wb(A[i], M)
            M = 0
            break
if M > 0:
    for i in range(N):
        while A[i] > 0 and M > 0:
            A[i] = A[i]//2
            M -= 1
print(sum(A))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = list(map(int, input().split()))
sub = [0]
a.sort()
for i in range (m):
    if (len(a) != 0):
        if (a[-1] >= sub[-1]):
            x =a.pop()
            sub.insert(1,x//2)
    else:
        x =sub.pop()
        sub.insert(1,x//2)
print(sum(a)+sum(sub))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
mvals = list(map(lambda x: -int(x), input().split()))

import heapq
heapq.heapify(mvals)

for _ in range(M):
    price = heapq.heappop(mvals)
    heapq.heappush(mvals, price / 2)

res = -int(sum(mvals))
print(res)

Submission status: Wrong Answer

Solution code:
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
sum = sum(A)
num = 0
for i in range(M):
    B = max(A)
    num += B - B // 2
print(sum-num)