input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
n,m = list(map(int, input().split())) a = list(map(int, input().split())) for _ in range(m): i = a.index(max(a)) a[i] = a[i]//2 print((sum(a)))
n,m = list(map(int, input().split())) a = list([int(x)*(-1) for x in input().split()]) import heapq heapq.heapify(a) for _ in range(m): num = heapq.heappop(a) heapq.heappush(a,(-num//2)*(-1)) print((-sum(a)))
p02912
import bisect N,M = list(map(int, input().split())) A_list = list(map(int, input().split())) A_list = sorted(A_list) #print(A_list) for i in range(M): val = A_list.pop()//2 bisect.insort_left(A_list, val, lo=min(N-1, max(0,(N-M) + i)) ) print((sum(A_list)))
import heapq N,M = list(map(int, input().split())) A_list = list(map(int, input().split())) for i in range(N): A_list[i] *= -1 heapq.heapify(A_list) for i in range(M): heapq.heappush(A_list, ((heapq.heappop(A_list) * -1 )// 2) * -1) print((sum(A_list) * -1))
p02912
n, m = list(map(int, input().split())) alist = list(map(int, input().split())) for i in range(m): num = max(alist) num = num >> 1 alist.remove(max(alist)) alist.append(num) print((sum(alist)))
import heapq n, m = list(map(int, input().split())) alist = list(map(int, input().split())) alist = list([-x for x in alist]) heapq.heapify(alist) for i in range(m): minus_max = alist[0] heapq.heapreplace(alist, ((-1)*minus_max >> 1)*(-1)) print((-1*sum(alist)))
p02912
# -*- coding: utf-8 -*- """ Created on Wed Oct 2 07:56:16 2019 @author: avina """ from queue import PriorityQueue as Q n,t = list(map(int,input().split())) q = Q() for i in input().split(): a = -1*int(i) q.put(a) while t >0: a = -1*(q.get()) a = -1*(a//2) q.put(a) t-=1 ans = 0 while q.qsize()>0: ans += q.get() print((-1*ans))
# -*- coding: utf-8 -*- """ Created on Thu Oct 3 07:43:37 2019 @author: avina """ import heapq class Maxheap(): def __init__(self, x): self.heap = [-e for e in x] heapq.heapify(self.heap) def push(self, value): heapq.heappush(self.heap, -value) def pop(self): return -heapq.heappop(self.heap) n,t = list(map(int, input().split())) l = list(map(int, input().split())) a = Maxheap(l) for i in range(t): b = a.pop()//2 a.push(b) sums = 0 for i in range(n): sums += a.pop() print(sums)
p02912
n,m=list(map(int,input().split())) l=list(map(int,input().split())) l=sorted(l) while m>0: a=l[len(l)-1] l.pop() l.append(a//2) l=sorted(l) m=m-1 print((sum(l)))
import heapq n,m=list(map(int,input().split())) l=list(map(int,input().split())) l=list([-x for x in l]) heapq.heapify(l) while m>0: a=heapq.heappop(l) if a//2==a/2: heapq.heappush(l,a//2) else: heapq.heappush(l,a//2+1) m=m-1 print((-sum(l)))
p02912
N, M = list(map(int, input().split())) A = sorted(list(map(int, input().split())), reverse = True) for _ in range(0, M, 1): A[0] >>= 1 for i in range(1, len(A), 1): if A[i - 1] < A[i]: A[i], A[i - 1] = A[i - 1], A[i] else: break print((sum(A)))
import heapq N, M = list(map(int, input().split())) A = list([-int(o) for o in input().split()]) heapq.heapify(A) for i in range(0, M, 1): heapq.heappush(A, -(-heapq.heappop(A) >> 1)) print((-sum(A)))
p02912
n, m = [int(v) for v in input().split()] values = sorted([int(v) for v in input().split()], reverse=True) def insert(arr, val): left, right = 0, len(arr) - 1 while right - left > 1: index = (left + right) // 2 if val <= arr[index]: left = index else: right = index return arr[0:(left + 1)] + [val] + arr[(left + 1):] for _ in range(m): v = values[0] >> 1 values = insert(values[1:], v) print((sum(values)))
from heapq import heappush, heappop, heapify n, m = [int(v) for v in input().split()] values = [-int(v) for v in input().split()] heapify(values) for _ in range(m): v = -((-heappop(values)) >> 1) heappush(values, v) print((-sum(values)))
p02912
n,m = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(m): index = a.index(max(a)) a[index] //= 2 print((sum(a)))
import heapq n,m = list(map(int, input().split())) a = list(map(int, input().split())) hq = [] for j in range(n): aa = a[j] * -1 heapq.heappush(hq, aa) for i in range(m): maxim = heapq.heappop(hq) * -1 maxim //= 2 maxim *= -1 heapq.heappush(hq, maxim) print((-1 * sum(hq)))
p02912
N,M=list(map(int,input().split())) A=list(map(int,input().split())) for i in range(M): A[A.index(max(A))]=((max(A))//2) print((sum(A)))
import heapq N,M=list(map(int,input().split())) A=list([int(x)*(-1) for x in input().split()]) heapq.heapify(A) for i in range(M): x=heapq.heappop(A) y=(((-1)*x)//2)*(-1) heapq.heappush(A,y) print(((-1)*sum(A)))
p02912
import bisect N, M = list(map(int, input().split())) A = list(map(int, input().split())) list.sort(A) # 昇順にソート for i in range(M): A[N-1] = A[N-1] // 2 tmp = A[N-1] del A[N-1] insert_index = bisect.bisect_left(A, tmp) A.insert(insert_index, tmp) print((sum(A)))
import heapq N, M = list(map(int, input().split())) A = list(map(int, input().split())) hq = [] for i in range(N): heapq.heappush(hq, A[i]*(-1)) for i in range(M): tmp = heapq.heappop(hq) * (-1) // 2 heapq.heappush(hq, tmp*(-1)) print((sum(hq)*(-1)))
p02912
x,y=list(map(int, input().split())) z=list(map(int, input().split())) t=0 for i in range(y): t=z.index(max(z)) z[t]=z[t]//2 print((sum(z)))
import heapq x,y=list(map(int, input().split())) z=list(map(int, input().split())) z = list([x*(-1) for x in z]) heapq.heapify(z) for i in range(y): k=heapq.heappop(z) heapq.heappush(z, -(-k//2)) z = list([x*(-1) for x in z]) print((sum(z)))
p02912
N,M = list(map(int,input().split())) A = sorted(list(map(int,input().split()))) for i in range(M): A = sorted(A) A[N-1] //= 2 print((sum(A)))
import heapq N,M = list(map(int,input().split())) A = sorted(list(map(int,input().split()))) A = [i * -1 for i in A] heapq.heapify(A) for i in range(M): maxA = -1 * heapq.heappop(A) heapq.heappush(A,-1*(maxA//2)) print((-sum(A)))
p02912
import heapq N, M = list(map(int, input().split())) A = list(map(int, input().split())) A = [-i for i in A] heapq.heapify(A) for _ in range(M): #Hは全部マイナスをつけたからaは最大値的なのはいる a = heapq.heappop(A) heapq.heappush(A, int(a/2)) print((-sum(A)))
import heapq N, M = list(map(int, input().split())) A = [-int(i) for i in input().split()] heapq.heapify(A) for _ in range(M): heapq.heapreplace(A, int(A[0]/2)) print((-sum(A)))
p02912
from sys import stdin s=stdin.readline().rstrip().split() N=int(s[0]) M=int(s[1]) count=0 a=stdin.readline().rstrip().split() for i in range(N): a[i]=int(a[i]) for i in range(M): a[a.index(max(a))]=a[a.index(max(a))]//2 print((sum(a)))
from sys import stdin import heapq s=stdin.readline().rstrip().split() N=int(s[0]) M=int(s[1]) a=stdin.readline().rstrip().split() for i in range(N): a[i]=int(a[i])*(-1) heapq.heapify(a) for i in range(M): t=-(-heapq.heappop(a)//2) heapq.heappush(a,t) print((sum(a)*(-1)))
p02912
import math N, M = list(map(int, input().split())) A = [int(i) for i in input().split()] def solve(): sorted_list = A for index in range(0, M): sorted_list = sorted(sorted_list) sorted_list[-1] = math.floor(sorted_list[-1] / 2) return sum(sorted_list) print((solve()))
import heapq N, M = list(map(int, input().split())) A = list(map(int, input().split())) def solve(): AA = [[-x, x] for x in A] heapq.heapify(AA) for i in range(M): x, y = heapq.heappop(AA) heapq.heappush(AA, [-(y//2), y//2]) AAA = [x[1] for x in AA] return sum(AAA) print((solve()))
p02912
import bisect import sys input = sys.stdin.readline n,m=list(map(int,input().split())) a=[int(i) for i in input().split()] a.sort() for _ in range(m): b=a[-1] a.pop() bisect.insort(a,b/2) print((sum( int( i//1) for i in a )))
import heapq n,m=list(map(int,input().split())) a=[-int(i) for i in input().split()] heapq.heapify(a) for i in range(m): b=-heapq.heappop(a) heapq.heappush(a,-b/2) print((int( sum(-i//1 for i in a)) ))
p02912
import heapq n,m=list(map(int,input().split())) a=[-int(i) for i in input().split()] heapq.heapify(a) for i in range(m): b=-heapq.heappop(a) heapq.heappush(a,-b/2) print((int( sum(-i//1 for i in a)) ))
n,m=list(map(int,input().split())) a=[-int(aa) for aa in input().split() ] import heapq heapq.heapify(a) for _ in range(m): now = -heapq.heappop(a) heapq.heappush(a,- (now//2) ) print((-sum(a)))
p02912
N, M = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(M): k = a.index(max(a)) a[k] //= 2 print((sum(a)))
import heapq N, M = list(map(int, input().split())) a = list([-int(x) for x in input().split()]) heapq.heapify(a) for i in range(M): heapq.heappush(a, int(heapq.heappop(a)/2)) print((-sum(a)))
p02912
n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() def price(x): return x // 2 for i in range(m): x = a.pop() a.append(price(x)) a.sort() print((sum(a)))
import heapq n, m = list(map(int, input().split())) price = list([int(x) * (-1) for x in input().split()]) heapq.heapify(price) for _ in range(m): max_price = -heapq.heappop(price) heapq.heappush(price, -(max_price//2)) ans = -sum(price) print(ans)
p02912
n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort(reverse=True) for j in range(m): if len(a) != 1: if a[0] >= a[1]: a[0] //= 2 else: a[1] //= 2 a.sort(reverse=True) else: a[0] //= 2 print((sum(a)))
n, m = list(map(int, input().split())) a = [int(i) for i in input().split()] a.sort(reverse=True) if n > 1: a.append(0) biggest = a[0] now = 0 while m > 0: a[now] = a[now]//2 m -= 1 biggest = a[0] for i in range(n-1): if a[i+1] >= biggest and m > 0: a[i+1] = a[i+1]//2 m -= 1 else: a.sort(reverse=True) break else: quit else: for j in range(m): a[0] //= 2 print((sum(a)))
p02912
import bisect n, m = list(map(int, input().split())) a = list(map(int, input().split())) a.sort() for i in range(m): nex_num = a[-1] // 2 del a[-1] a.insert(bisect.bisect_left(a, nex_num), nex_num) print((sum(a)))
n, m = list(map(int, input().split())) a = list(map(int, input().split())) a_minus = [-x for x in a] import heapq heapq.heapify(a_minus) for i in range(m): nex_num = heapq.heappop(a_minus) nex_num = (-1 * nex_num) // 2 * -1 heapq.heappush(a_minus, nex_num) print((-sum(a_minus)))
p02912
n, m = list(map(int,input().split())) price = list(map(int, input().split())) price.sort(reverse=True) while m != 0: price[0] //= 2 for i in range(1,n): if price[0] > price[i]: price_buf = price[1:i] price[i-1] = price[0] price[0:i-1] = price_buf break m -= 1 print((sum(price)))
import heapq n, m = list(map(int,input().split())) price = list(map(int, input().split())) price = list([x*(-1) for x in price]) heapq.heapify(price) while m != 0: maxv = heapq.heappop(price) heapq.heappush(price, (maxv+1) // 2) m -= 1 print((sum(price) * (-1)))
p02912
import heapq n, m = list(map(int, input().split())) a = [] #a = list(map(int, input().split())) #a = list(reversed(sorted(a))) #heapq.heapify(a) for i in input().split(): heapq.heappush(a, -int(i)) ans = 0 for i in range(len(a)): while True: if m <= 0: break maxV = heapq.heappop(a) # print('maxV: ' + str(maxV)) heapq.heappush(a, -(-maxV // 2)) m -= 1 # print('m: ' + str(m)) # print('a: ' + str(a)) ans = -sum(a) print(ans)
import heapq n, m = list(map(int, input().split())) a = [] for i in input().split(): heapq.heappush(a, -int(i)) for j in range(m): highest = heapq.heappop(a) heapq.heappush(a, -(-highest // 2)) print((-sum(a)))
p02912
import math import bisect N, M = list(map(int, input().split())) A = sorted(list(map(int, input().split()))) for i in range(M): n = A.pop() // 2 bisect.insort(A, n) for j in range(N): A[j] = math.floor(A[j]) print((sum(A)))
from heapq import heapify, heappop, heappush N, M = list(map(int, input().split())) A = list(map(int, input().split())) A_minus = [-x for x in A] heapify(A_minus) for i in range(M): n = -heappop(A_minus) // 2 heappush(A_minus, -n) print((-sum(A_minus)))
p02912
N, M = list(map(int, input().split())) A = list(map(float, input().split())) for i in range(M): A[A.index(max(A))] /= 2 yen = 0 for i in range(N): yen += int(A[i]) print(yen)
import sys import math from collections import deque import heapq sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 input = lambda: sys.stdin.readline().strip() NI = lambda: int(eval(input())) NMI = lambda: list(map(int, input().split())) NLI = lambda: list(NMI()) SI = lambda: eval(input()) def main(): N, M = NMI() A = NLI() A = [-a for a in A] heapq.heapify(A) for i in range(M): a_max = -heapq.heappop(A) a_max = a_max // 2 heapq.heappush(A, -a_max) print((-sum(A))) if __name__ == "__main__": main()
p02912
def main(): import sys import heapq input=sys.stdin.readline N,M=list(map(int,input().split())) A=list([-1*int(x) for x in input().split()]) for i in range(M): heapq.heapify(A) if i==0: temp = -(heapq.heappop(A))//2 else: heapq.heappush(A,-temp) temp = -(heapq.heappop(A))//2 print((-sum(A)+temp)) if __name__ == '__main__': main()
def main(): import sys import heapq input=sys.stdin.readline N,M=list(map(int,input().split())) A=list([-1*int(x) for x in input().split()]) heapq.heapify(A) for i in range(M): if i==0: temp = -(heapq.heappop(A))//2 else: heapq.heappush(A,-temp) temp = -(heapq.heappop(A))//2 print((-sum(A)+temp)) if __name__ == '__main__': main()
p02912
import math n, m = list(map(int, input().split())) A = list(map(int, input().split())) a = sorted(A, reverse = True) cnt = 0 ans = 0 while cnt < m: max_a = max(a) for i in range(n): if cnt == m: break if a[i] == max_a: cnt += 1 a[i] = a[i]/2 for j in a: ans += math.floor(j) print(ans)
import heapq, math n, m = list(map(int, input().split())) A = list(map(int, input().split())) a = list([x*(-1) for x in A]) heapq.heapify(a) for i in range(m): max_a = heapq.heappop(a) heapq.heappush(a, math.ceil(max_a/2)) print((-sum(a)))
p02912
# 優先度付キューのimport import heapq n, m = list(map(int, input().split())) a = [int(i) * -1 for i in input().split()] heapq.heapify(a) for i in range(m): minPrice = heapq.heappop(a) # 負の切捨てが面倒なので正の値にしてからまた負に戻す minPrice = -(abs(minPrice) // 2) heapq.heappush(a, minPrice) sum = 0 for i in a: sum += -i print(sum)
# 優先度付キューのimport import heapq n, m = list(map(int, input().split())) a = [int(i) * -1 for i in input().split()] heapq.heapify(a) for i in range(m): minPrice = heapq.heappop(a) # 負の切捨てが面倒なので正の値にしてからまた負に戻す minPrice = -(abs(minPrice) // 2) heapq.heappush(a, minPrice) print((-sum(a)))
p02912
import math N, M = list(map(int, input().split())) A = list(map(int, input().split())) # 以下を割引券の枚数分繰り返す # 品物の値段を高い順にソート # 最も高い品物に割引券を1枚使う for i in range(M): A.sort(reverse=True) A[0] = math.floor(A[0] / 2) print((sum(A)))
import heapq N, M = list(map(int, input().split())) A = list([int(x) * (-1) for x in input().split()]) heapq.heapify(A) # 以下を割引券の枚数分繰り返す # 最も高い品物に割引券を1枚使う for _ in range(M): min = heapq.heappop(A) heapq.heappush(A, (-1) * (-min // 2)) print((-sum(A)))
p02912
import math n, m = list(map(int, input().split())) a = list(map(int, input().split())) d = {} for i in range(n): if a[i] in d: l = d[a[i]] l.append(i) d[a[i]] = l else: d[a[i]] = [i] for i in range(m): b = max(a) li = d[b] li0 = li.pop(0) d[b] = li a[li0] = b/2 if b/2 in d: l = d[b/2] l.append(li0) d[b/2] = l else: d[b/2] = [li0] ans = 0 for i in a: ans += math.floor(i) print(ans)
import math import heapq n, m = list(map(int, input().split())) a = list(map(int, input().split())) hq = [] for i in range(n): heapq.heappush(hq, a[i]*(-1)) for i in range(m): b = heapq.heappop(hq) b = ((-1)*b)//2 heapq.heappush(hq, b*(-1)) ans = 0 for i in hq: ans += i *(-1) print(ans)
p02912
from sys import stdin from bisect import insort def main(): N, M = [int(x) for x in stdin.readline().rstrip().split()] As = [int(x) for x in stdin.readline().rstrip().split()] As.sort() for _ in range(M): x = As[-1] / 2 insort(As, x) del As[-1] sum_ = 0 for x in As: sum_ += int(x) print(sum_) if __name__ == "__main__": main()
from sys import stdin import heapq def main(): N, M = [int(x) for x in stdin.readline().rstrip().split()] As = [] for i in [int(x) for x in stdin.readline().rstrip().split()]: heapq.heappush(As, -i) for _ in range(M): x = heapq.heappop(As) heapq.heappush(As, x / 2) print((sum([-1 * int(x) for x in As]))) if __name__ == "__main__": main()
p02912
from sys import stdin import heapq def main(): N, M = [int(x) for x in stdin.readline().rstrip().split()] As = [] for i in [int(x) for x in stdin.readline().rstrip().split()]: heapq.heappush(As, -i) for _ in range(M): x = heapq.heappop(As) heapq.heappush(As, x / 2) print((sum([-1 * int(x) for x in As]))) if __name__ == "__main__": main()
from sys import stdin import heapq def main(): N, M = [int(x) for x in stdin.readline().rstrip().split()] As = [] for i in [int(x) for x in stdin.readline().rstrip().split()]: heapq.heappush(As, -i) for _ in range(M): x = heapq.heappop(As) heapq.heappush(As, -(-x // 2)) print((sum([-1 * x for x in As]))) if __name__ == "__main__": main()
p02912
N, M = list(map(int, input().split())) A = list(map(int, input().split())) A.sort(reverse=True) for i in range(M): max_index = A.index(max(A)) A[max_index] = A[max_index]//2 print((sum(A)))
import heapq N, M = list(map(int, input().split())) A = [-i for i in map(int, input().split())] heapq.heapify(A) for i in range(M): tmp = -((-heapq.heappop(A))//2) heapq.heappush(A, tmp) print((-sum(A)))
p02912
N = list(map(int, (input().split(' ')))) A = list(map(int, (input().split(' ')))) for i in range(N[1]): for Index, Kakaku in enumerate(A): if Kakaku == max(A): A[Index] = int(Kakaku / 2) break print((sum(A)))
import heapq N = list(map(int, (input().split(' ')))) A = list([x*(-1) for x in list(map(int, (input().split(' '))))]) heapq.heapify(A) for i in range(N[1]): heapq.heappush(A, int(heapq.heappop(A) / 2)) print((-sum(A)))
p02912
import heapq N = list(map(int, (input().split(' ')))) A = list([x*(-1) for x in list(map(int, (input().split(' '))))]) heapq.heapify(A) for i in range(N[1]): heapq.heappush(A, int(heapq.heappop(A) / 2)) print((-sum(A)))
import heapq def FUNCTION(A, M): heapq.heapify(A) for i in range(M): heapq.heappush(A, int(heapq.heappop(A) / 2)) return -sum(A) N = list(map(int, (input().split(' ')))) A = list([x*(-1) for x in list(map(int, (input().split(' '))))]) print((FUNCTION(A, N[1])))
p02912
N, M = list(map(int, input().split())) Alist = list(map(int, input().split())) # Alistの値段の高いモノから割引券を使った方がよい while M > 0: max_index = Alist.index(max(Alist)) Alist[max_index] = Alist[max_index]//2 M = M - 1 print((sum(Alist)))
import heapq N, M = list(map(int, input().split())) Alist = list([int(x) * (-1) for x in input().split()]) heapq.heapify(Alist) for _ in range(M): a = heapq.heappop(Alist) * (-1) a = a // 2 heapq.heappush(Alist, a * (-1)) print((sum(Alist) * (-1)))
p02912
import heapq n, m = list(map(int, input().split())) aa = list(map(int, input().split())) h = [(-a, a) for a in aa] heapq.heapify(h) for _ in range(m): x = h[0] c = x[1] // 2 x = (-c, c) heapq.heapreplace(h, x) print((sum([-hh[0] for hh in h])))
import heapq n, m = list(map(int, input().split())) aa = list(map(int, input().split())) h = [-a for a in aa] heapq.heapify(h) for _ in range(m): x = h[0] heapq.heapreplace(h, -(-x // 2)) print((sum([-hh for hh in h])))
p02912
n,m=list(map(int,input().split())) a=list(map(int,input().split())) a.sort() for i in range(m): a[a.index(max(a))]=max(a)//2 print((sum(a)))
import heapq n,m=list(map(int,input().split())) a=list([int(x)*(-1) for x in input().split()]) heapq.heapify(a) for i in range(m): max=heapq.heappop(a) heapq.heappush(a,(max*(-1)//2)*(-1)) print((sum(a)*(-1)))
p02912
from heapq import heappush, heappop from collections import deque,defaultdict,Counter import itertools from itertools import permutations,combinations import sys import bisect import string import math import time import random def I(): return int(input()) def MI(): return map(int,input().split()) def LI(): return [int(i) for i in input().split()] def LI_(): return [int(i)-1 for i in input().split()] def show(*inp,end='\n'): if show_flg: print(*inp,end=end) YN=['Yes','No'] mo=10**9+7 ts=time.time() sys.setrecursionlimit(10**6) #input=sys.stdin.readline show_flg=False show_flg=True an=0 n,m=MI() a=LI() q=[] for i in a: heappush(q,-i) for i in range(m): x=-heappop(q) x//=2 heappush(q,-x) print(-sum(q))
from heapq import* n,m=list(map(int,input().split())) q=[] [heappush(q,-int(i)) for i in input().split()] for i in range(m): x=-heappop(q)//2 heappush(q,-x) print((-sum(q)))
p02912
n,m=list(map(int,input().split())) A=list(map(int,input().split())) while m>0: A.sort(reverse=True) A[0]=A[0]//2 m-=1 print((sum(A)))
import heapq n,m=list(map(int,input().split())) A=list(map(int,input().split())) q=[] for a in A: heapq.heappush(q,-a) for _ in range(m): p=-heapq.heappop(q)//2 heapq.heappush(q,-p) print((-sum(q)))
p02912
N, M = list(map(int, input().split())) A = [int(i) for i in input().split()] while M > 0: A[A.index(max(A))] //= 2 M -= 1 print((sum(A)))
from heapq import heapify, heappush, heappop N, M = list(map(int, input().split())) A = [-int(i) for i in input().split()] heapify(A) while M > 0: heappush(A, heappop(A) / 2) M -= 1 print((-sum(int(i) for i in A)))
p02912
def pushHeap(array, elem): n = len(array) array.append(elem) while n != 0: i = int((n - 1) / 2) if array[n] > array[i]: tmp = array[n] array[n] = array[i] array[i] = tmp n = i def popHeap(array): n = len(array) - 1 array[0] = array[n] del array[-1] i = 0 while 2 * i + 1 < n: j = 2 * i + 1 if j != n - 1 and array[j] < array[j + 1]: j += 1 if array[i] < array[j]: tmp = array[j] array[j] = array[i] array[i] = tmp i = j N, M = list(map(int, input().split())) A = list(map(int, input().split())) heap_A = [] for a in A: pushHeap(heap_A, a) for _ in range(M): discount_max = int(heap_A[0] / 2) popHeap(heap_A) pushHeap(heap_A, discount_max) print((sum(heap_A)))
import heapq N, M = list(map(int, input().split())) A = list([int(x) * -1 for x in input().split()]) heapq.heapify(A) for _ in range(M): a_min = heapq.heappop(A) heapq.heappush(A, -1 * (-a_min//2)) print((-sum(A)))
p02912
n,m=list(map(int,input().split())) a=list(map(int,input().split())) a.sort(reverse=True) for i in range(m): a[0]=a[0]/2 for j in range(1,n): if a[0]>a[j]: a.insert(j,a[0]) del a[0] break import math ans=0 for i in range(n): ans=ans+math.floor(a[i]) print(ans)
n,m=list(map(int,input().split())) a=list(map(int,input().split())) for i in range(n): a[i]=a[i]*-1 import heapq heapq.heapify(a) for i in range(m): t=(heapq.heappop(a))*-1 heapq.heappush(a,(t//2)*-1) print((sum(a)*-1))
p02912
from heapq import heappush, heappop N,M = list(map(int, input().split())) hq = [] a = [int(i) for i in input().split()] for i in range(N): heappush(hq, -a[i]) for i in range(M): tmp = -heappop(hq) // 2 heappush(hq, -tmp) print((-sum(hq)))
from heapq import heappush, heappop, heapify N,M = list(map(int, input().split())) hq = [-int(i) for i in input().split()] heapify(hq) for i in range(M): tmp = -heappop(hq) // 2 heappush(hq, -tmp) print((-sum(hq)))
p02912
from heapq import heappush, heappop N,M = list(map(int, input().split())) hq = [] for i in input().split(): heappush(hq, -int(i)) for i in range(M): tmp = -heappop(hq) // 2 heappush(hq, -tmp) print((-sum(hq)))
from heapq import heappush, heappop, heapify def main(): N,M = list(map(int, input().split())) hq = [-int(i) for i in input().split()] heapify(hq) for i in range(M): tmp = -heappop(hq) // 2 heappush(hq, -tmp) print((-sum(hq))) if __name__ == "__main__": main()
p02912
import heapq # import collection # import bisect # import numpy N, M = list(map(int, input().split())) A = list(map(int, input().split())) # N = 10**5 # A = [10 for i in range(10**5)] # M = 10**5 # A = sorted(A) heapq.heapify(A) while M > 0: i = heapq.nlargest(1, enumerate(A), key=lambda x: x[1]) A[i[0][0]] = A[i[0][0]] // 2 M -= 1 print((sum(A)))
import heapq # import collection # import bisect # import numpy N, M = list(map(int, input().split())) # A = list(map(int, input().split())) # N = 10**5 # A = [10 for i in range(10**5)] # M = 10**5 # A = sorted(A) A = [] for i in input().split(): heapq.heappush(A, -int(i)) while M > 0: heapq.heappush(A, -((-heapq.heappop(A))//2)) M -= 1 print((-sum(A)))
p02912
import heapq N,M = list(map(int,input().split())) A = list(map(int,input().split())) A = [-A[i] for i in range(N)] A = sorted(A) cnt = 0 while cnt<M: a = heapq.heappop(A)*(-1) a = a/2 heapq.heappush(A,-a) cnt += 1 A = [int(-A[i]) for i in range(N)] print((sum(A)))
import heapq N,M = list(map(int,input().split())) A = list(map(int,input().split())) heap = [] for i in range(N): heapq.heappush(heap,-A[i]) for _ in range(M): a = heapq.heappop(heap) a = -a a = a//2 heapq.heappush(heap,-a) print((-sum(heap)))
p02912
import heapq n, m = list(map(int, input().split())) a = list(map(int, input().split())) a = [-i for i in a] heapq.heapify(a) for i in range(m): c = heapq.heappop(a) c = -c // 2 heapq.heappush(a, -c) if sum(a) == 0: break print((-sum(a)))
import heapq n, m = list(map(int, input().split())) a = list(map(int, input().split())) a = [-i for i in a] heapq.heapify(a) for i in range(m): c = heapq.heappop(a) c = -c // 2 heapq.heappush(a, -c) if a[0] == 0: break print((-sum(a)))
p02912
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() hq = [] heapq.heapify(hq) ans = 0 for i in range(n): tt = a[i] heapq.heappush(hq,-tt) for i in range(m): tmp = heapq.heappop(hq) tmp /= 2 heapq.heappush(hq,tmp) # print(hq) for i in range(n): tttt = heapq.heappop(hq) ans -= math.ceil(tttt) print(ans)
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n,m = inpl() a = inpl() a = [-x for x in a] heapify(a) for _ in range(m): now = heappop(a) now /= 2 heappush(a,now) # print(now) res = 0 for x in a: res += int(-x) print(res)
p02912
import bisect n, m = list(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)))
import heapq def neg_int(a): return -1 * int(a) n, m = list(map(int, input().split())) a = sorted(list(map(neg_int, input().split()))) heapq.heapify(a) for i in range(m): value = -1 * ((-1 * heapq.heappop(a)) // 2) heapq.heappush(a, value) print((sum(a) * -1))
p02912
import bisect N, M = list(map(int, input().split())) A = sorted([int(x) for x in input().split()]) while M > 0: a = A.pop() bisect.insort(A, a//2) M -= 1 print((sum(A)))
import heapq N, M = list(map(int, input().split())) A = [-int(x) for x in input().split()] heapq.heapify(A) for _ in range(M): tmin = heapq.heappop(A) heapq.heappush(A, (-1)*(-tmin//2)) print((-sum(A)))
p02912
N,M = list(map(int , input().split(" "))) A = list(map(int, input().split(" "))) for i in range(M): A.sort() A[N-1] = int(A[N-1] / 2) result = 0 for i in range(N): result += A[i] print(result)
import heapq N,M = list(map(int , input().split(" "))) A = list(map(int, input().split(" "))) A_q = list([x*(-1) for x in A]) heapq.heapify(A_q) for i in range(M): max = heapq.heappop(A_q) * (-1) // 2 heapq.heappush(A_q, -max) result = 0 A_q = list([x*(-1) for x in A_q]) for i in range(N): result += A_q[i] print(result)
p02912
def main(): import bisect n,m = list(map(int,input().split())) a = sorted(list(map(int,input().split()))) for _ in range(m): x= a.pop(-1)/2 index = bisect.bisect_left(a, x) a.insert(index, x) print((int(sum(i//1 for i in a)))) if __name__=='__main__': main()
def main(): import heapq n,m = list(map(int,input().split())) a =sorted(list([int(x)*(-1) for x in input().split()])) heapq.heapify(a) for _ in range(m): x=heapq.heappop(a)/2 heapq.heappush(a,x) print((int(sum((-1)*i//1 for i in a)))) if __name__=='__main__': main()
p02912
import sys def input(): return sys.stdin.readline()[:-1] n,m=list(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))
import sys def input(): return sys.stdin.readline()[:-1] n,m=list(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) print((sum(a)*-1))
p02912
n, m = list(map(int, input().split())) a = list(map(int, input().split())) # a.sort(reverse=True) for i in range(m): a[a.index(max(a))] /= 2 ans = 0 for i in range(n): ans += a[i] // 1 print((int(ans)))
import heapq n, m = list(map(int, input().split())) a = list(map(int, input().split())) a = list([x*(-1) for x in a]) heapq.heapify(a) for i in range(m): heapq.heappush(a, heapq.heappop(a) / 2) ans = 0 for i in range(n): ans += -a[i] // 1 print((int(ans)))
p02912
import bisect n, m = list(map(int, input().split())) a = sorted(list(map(int, input().split()))) for i in range(m): x = a.pop() // 2 bisect.insort_right(a, x) print((sum(a)))
import heapq n, m = list(map(int, input().split())) a = list(map(int, input().split())) a = list([x * (-1) for x in a]) heapq.heapify(a) for i in range(m): x = heapq.heappop(a) heapq.heappush(a, (-1) * (-x // 2)) print((-sum(a)))
p02912
n, m = list(map(int, input().split())) a = list(map(int, input().split())) for _ in range(m): maxid = a.index(max(a)) a[maxid] = a[maxid] // 2 print((sum(a)))
from heapq import heapify, heappop, heappush import math n, m = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(n): a[i] = a[i] * -1 heapify(a) for _ in range(m): minval = heappop(a) heappush(a, math.ceil(minval / 2)) ans = 0 for i in range(n): ans += int(a[i]) print((-ans))
p02912
NM = input().split(" ") A_LIST = input().split(" ") A = [] for i in A_LIST: A.append(int(i)) N = int(NM[0]) M = int(NM[1]) #.sort() for i in range(0, M): m = max(A) n = A.index(m) m = m // 2 A[n] = m S = 0 for i in A: S += i print(S)
import heapq NM =input().split(" ") A_LIST = input().split(" ") N = int(NM[0]) M = int(NM[1]) A = [] for i in A_LIST: heapq.heappush(A, -1 * int(i)) for i in range(0, M): m = heapq.heappop(A) m = -1 * m m = m // 2 heapq.heappush(A, -1 * m) S = 0 for i in A: S += (-1 * i) print(S)
p02912
from collections import Counter import math N,M=list(map(int,input().split())) A=list(map(int,input().split())) #rec(N-1,M) res=dict(Counter(A)) while M>0: #ex=max(list(map(float,res.keys()))) ex=max(res.keys()) n=res[ex] val=ex//2 if n<=M: M-=n del res[ex] if val in list(res.keys()): res[val]+=n else: res[val]=n else: n=M res[ex]-=n if val in list(res.keys()): res[val]+=n else: res[val]=n M=0 ans=0 for i in list(res.keys()): ans+=i*res[i] print((int(ans)))
import heapq import math n,m=list(map(int,input().split())) a=list([-1*int(x) for x in input().split()]) heapq.heapify(a) for _ in range(m): tmp=heapq.heappop(a) cal=math.ceil(tmp/2) heapq.heappush(a,cal) print((sum(a)*-1))
p02912
import copy n,m=list(map(int,input().split())) a=list(map(int,input().split())) aorg=a[:] waribiki=[0]*n for i in range(m): maxindex=a.index(max(a)) a[maxindex]=a[maxindex]/2 waribiki[maxindex]+=1 total=0 for i in range(n): if waribiki[i]!=0: aorg[i]=aorg[i]//(2**waribiki[i]) total+=aorg[i] print (total)
import copy import heapq import math n,m=list(map(int,input().split())) a=[0]*n atmp=list(map(int,input().split())) for i in range(n): a[i]=-atmp[i] heapq.heapify(a) for i in range(m): tmp=heapq.heappop(a) heapq.heappush(a,tmp/2) total=0 for i in range(n): total+=math.ceil(a[i]) print((-total))
p02912
N, M = list(map(int, input().split())) A = sorted(list(map(int, input().split())), reverse=True) for i in range(M): a = A.pop(0) // 2 f = 0 for j in range(N-2): if A[j] >= a >= A[j+1]: A.insert(j+1, a) f = 1 break if f == 0: A.append(a) print((sum(A)))
import heapq N, M = list(map(int, input().split())) A = list(list([int(x) * (-1) for x in input().split()])) heapq.heapify(A) for i in range(M): heapq.heappush(A, (-1) * ((-1 * heapq.heappop(A)) // 2)) print((-1 * sum(A)))
p02912
import math n, m = list(map(int, input().split())) a = list(map(int, input().split())) for i in range(m): a.sort() a[-1]=math.floor(a[-1]/2) print((sum(a)))
import heapq n, m = list(map(int, input().split())) a = list([int(x)*-1 for x in input().split()]) heapq.heapify(a) for i in range(m): m = heapq.heappop(a) heapq.heappush(a, (-m//2)*-1) print((-sum(a)))
p02912
from bisect import insort_left N, M = list(map(int,input().split())) A = list(map(int,input().split())) A.sort() for i in range(M): x = A.pop() insort_left(A,x//2) print((sum(A)))
import heapq N, M = list(map(int,input().split())) A = list(map(int,input().split())) A = list([-x for x in A]) heapq.heapify(A) for i in range(M): x = heapq.heappop(A) heapq.heappush(A,x/2) ans = 0 for i in range(N): x = heapq.heappop(A) ans += int(-x) print(ans)
p02912
n,m=list(map(int,input().split())) a=list(map(int,input().split())) a=sorted(a,reverse=True) for _ in range(m): a[0]=a[0]//2 a=sorted(a,reverse=True) print((sum(a)))
import heapq n,m=list(map(int,input().split())) a=list(map(int,input().split())) for i in range(n): a[i]*=-1 heapq.heapify(a) for _ in range(m): x=heapq.heappop(a)*(-1) x=x//2 heapq.heappush(a,-x) print((sum(a)*(-1)))
p02912
import sys import heapq input = sys.stdin.readline n, m = list(map(int, input().split())) li = [-int(i) for i in input().split()] for _ in range(m): heapq.heapify(li) x = heapq.heappop(li) if x % 2 == 0: heapq.heappush(li, x // 2) else: heapq.heappush(li, x // 2 + 1) print((-sum(list(li))))
import sys import heapq input = sys.stdin.readline n, m = list(map(int, input().split())) li = [-int(i) for i in input().split()] li = sorted(li) for _ in range(m): x = heapq.heappop(li) #print(x) if x % 2 == 0: heapq.heappush(li, x // 2) else: heapq.heappush(li, x // 2 + 1) #print(li) print((-sum(list(li))))
p02912
from heapq import heapify,heappush,heappop from math import ceil n,m,*a=list(map(int,open(0).read().split())) a=[(-1)*x for x in a] heapify(a) for _ in range(m): x=heappop(a) heappush(a,ceil(x/2)) print((-sum(a)))
from heapq import*;n,m,*a=[-int(x) for x in open(0).read().split()];heapify(a) for _ in[0]*-m:heappush(a,0-heappop(a)//-2) print((-sum(a)))
p02912
# from pprint import pprint # import math # import collections # n = int(input()) n, m = list(map(int, input().split(' '))) a = list(map(int, input().split(' '))) for _m in range(m): a = sorted(a, reverse=True) a[0] = a[0] // 2 ans = sum(a) print(ans)
# from pprint import pprint import math # import collections # n = int(input()) n, m = list(map(int, input().split(' '))) a = list([int(x) * (-1) for x in input().split(' ')]) # a = sorted(a, reverse=True) # b = [math.log2(_a) for _a in a] import heapq q_a = heapq.heapify(a) for m in range(m): x = heapq.heappop(a) * (-1) heapq.heappush(a, (x // 2) * (-1)) print((sum(a) * (-1)))
p02912
import bisect import copy N,M = list(map(int,input().split())) A = sorted(list(map(int,input().split()))) A2 = copy.deepcopy(A[N-M:]) for _ in range(M): tmp_a = int(A2[-1]/2) del A2[-1] A2.insert(bisect.bisect_left(A2,tmp_a),tmp_a) print((sum(A[:N-M])+sum(A2)))
import heapq N,M = list(map(int,input().split())) A = [] for a in map(int,input().split()): heapq.heappush(A,-a) cnt = 0 while cnt < M: a = heapq.heappop(A) heapq.heappush(A,-((-a)//2)) cnt += 1 print((-sum(A)))
p02912
N,M = list(map(int,input().split())) A = list(map(int,input().split())) cnt = 0 while cnt < M: a = max(A) A[A.index(a)] = a//2 cnt += 1 print((sum(A)))
import heapq from math import ceil n,m = list(map(int,input().split())) a = [-int(i) for i in input().split()] heapq.heapify(a) for i in range(m): heapq.heappush(a,ceil(heapq.heappop(a)/2)) print((-sum(a)))
p02912
N, M = list(map(int, input().split())) A = list(map(int, input().split())) import bisect for i in range(M): M = max(A) A.remove(M) x = M//2 A.append(x) print((sum(A)))
N, M = list(map(int, input().split())) A = list([(-1)*int(x) for x in input().split()]) import heapq # heapqライブラリのimport heapq.heapify(A) # リストを優先度付きキューへ # 最小値の取り出し for i in range(M): heapq.heappush(A, ((-1)*heapq.heappop(A))//2*(-1)) print((sum(A)*(-1)))
p02912
# input n, m = list(map(int, input().split())) la = sorted(list(map(int, input().split())), reverse=True) while m > 0: d = 0 for i in range(n): if i < n-1 and la[i] >= la[i+1]: if la[i+1] > 0: d = la[i] // la[i+1] else: d = 1 if d > m: d = m la[i] = la[i] // (2**d) else: la[i] = la[i] // (2**d) #print(la) for j in range(i, n-1): if la[j] <= la[j+1]: tmp = la[j] la[j] = la[j+1] la[j+1] = tmp else: break break else: la[i] = la[i] // 2 d = 1 break #la.sort(reverse=True) #print(la) # sprint(d) m -= d print((sum(la)))
import heapq as h # input n, m = list(map(int, input().split())) la = list([int(x)*-1 for x in input().split()]) h.heapify(la) while m > 0: max = abs(la[0]) h.heapreplace(la, (max // 2)*-1) m -= 1 print((abs(sum(la))))
p02912
x,y = list(map(int,input().split())) li = list(map(int,input().split())) score = 0 for i in range(y): li[li.index(max(li))] //= 2 print((sum(li)))
import heapq n, m = list(map(int,input().split())) li = list([int(x)*(-1) for x in input().split()]) heapq.heapify(li) for i in range(m): a = heapq.heappop(li) a = (-a) // 2 heapq.heappush(li,-a) print((-sum(li)))
p02912
n, m = list(map(int, input().split())) A = list(map(int, input().split())) i=0 while i<m: i+=1 t=A.index(max(A)) A[t]=A[t]//2 print((sum(A)))
N, M = list(map(int,input().split())) A = list(map(int,input().split())) A.sort(reverse = True) it = 0 for i in range(M): A[it]=A[it]//2 if it<N-1: if A[it]<A[it+1] and A[0]<A[it+1]: it+=1 else: A.sort(reverse = True) it = 0 if it == N-1: A.sort(reverse = True) it = 0 print((sum(A)))
p02912
n, m = list(map(int, input().split())) a = list(map(float, input().split())) a.sort() for t in range(m): discount = a.pop() / 2. inserted = False for i in range(n - 1): if a[i] > discount: a.insert(i, discount) inserted = True break if not inserted: a.append(discount) print((sum(map(int, a))))
import heapq n, m = list(map(int, input().split())) a = list([-float(x) for x in input().split()]) heapq.heapify(a) for t in range(m): discount = heapq.heappop(a) / 2. heapq.heappush(a, discount) print((sum([int(-x) for x in a])))
p02912
N, M = list(map(int, input().split())) A = list(map(int,input().split())) # dp = [[0 for i in range(N)] for _ in range(M)] # sortedA = sorted(A,reverse=True) for i in range(M): m = max(A) A[A.index(m)] = m//2 print((sum(A)))
import heapq as hq N, M = list(map(int, input().split())) A = list(map(int,input().split())) # dp = [[0 for i in range(N)] for _ in range(M)] # sortedA = sorted(A,reverse=True) A = list([x*-1 for x in A]) hq.heapify(A) for i in range(M): m=hq.heappop(A)*-1 hq.heappush(A,(m//2)*-1) # print(A) print((abs(sum(A))))
p02912
N, M = list(map(int, input().split())) prices = list(map(int, input().split())) for i in range(M): max_idx = prices.index(max(prices)) prices[max_idx] = prices[max_idx] // 2 print((sum(prices)))
import heapq N, M = list(map(int, input().split())) A = list(map(int, input().split())) A = list([x * (-1) for x in A]) heapq.heapify(A) for _ in range(M): tmp = heapq.heappop(A) * (-1) tmp //= 2 heapq.heappush(A, tmp * (-1)) print((-sum(A)))
p02912
import sys input = sys.stdin.readline n, m = list(map(int, input().split())) val = list(map(int,input().split())) my_index = val.index for i in range(m): val[my_index(max(val))] = max(val)//2 print((sum(val)))
import heapq import sys input = sys.stdin.readline n, m = list(map(int, input().split())) a = [int(i) for i in input().split()] for i in range(n): a[i] *= -1 heapq.heapify(a) for i in range(m): heapq.heapreplace(a, int(a[0] / 2)) print((sum(a)*-1))
p02912
import sys import heapq import math input = sys.stdin.readline n, m = list(map(int, input().split())) a = list([int(x) * (-1) for x in input().split()]) heapq.heapify(a) for i in range(m): max_a = heapq.heappop(a) max_a /= 2 heapq.heappush(a, max_a) for i in range(n): a[i] = math.floor(-a[i]) print((sum(a)))
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) import heapq n, m = list(map(int, readline().split())) a = list([int(x)*(-1) for x in readline().split()]) heapq.heapify(a) for i in range(m): memo = heapq.heappop(a) heapq.heappush(a, (-memo // 2) * (-1)) print((-sum(a)))
p02912
N, M = list(map(int, input().split())) A = list(map(int, input().split())) for i in range(M): A[A.index(max(A))] //= 2 print((sum(A)))
import heapq N, M = list(map(int, input().split())) A = list([int(x)*(-1) for x in input().split()]) heapq.heapify(A) for i in range(M): x = heapq.heappop(A) * -1 x //= 2 heapq.heappush(A, x*(-1)) print((sum(A)*(-1)))
p02912
import heapq n, m = list(map(int, input().split())) a = list(map(int, input().split())) a = list([x*(-1) for x in a]) heapq.heapify(a) for i in range(m): heapq.heappush(a, ((heapq.heappop(a)*-1//2)*(-1))) print((sum(a)*-1))
import heapq n, m = list(map(int, input().split())) a = [-int(i) for i in input().split()] heapq.heapify(a) for _ in range(m): heapq.heappush(a, ((heapq.heappop(a)*-1//2)*(-1))) print((sum(a)*-1))
p02912
n,m=list(map(int,input().split())) a=sorted(list(map(int,input().split())))[::-1] i=0 while True: a[i]=a[i]//2 a=sorted(a)[::-1] m-=1 if m==0: break print((sum(a)))
import heapq n,m=list(map(int,input().split())) a=list([int(i)*(-1) for i in input().split()]) heapq.heapify(a) for i in range(m): x=heapq.heappop(a)*(-1) heapq.heappush(a,(x//2)*(-1)) print(((-1)*sum(a)))
p02912
n,m = list(map(int,input().split())) a_list = list(map(int,input().split())) for i in range(m): a_list[a_list.index(max(a_list))] =a_list[a_list.index(max(a_list))]//2 print((sum(a_list)))
n,m = list(map(int,input().split())) import math a_list = list(map(int,input().split())) for i in range(n): a_list[i] = -1 * a_list[i] import heapq heapq.heapify(a_list) for j in range(m): a = heapq.heappop(a_list) a = math.ceil(a/2) heapq.heappush(a_list,a) print((-1 * sum(a_list)))
p02912
import heapq N,M=list(map(int,input().split())) A=list(map(int,input().split())) for i in range(N): A[i]*=-1 #print(A) heapq.heapify(A) for i in range(M): temp=heapq.heappop(A) # print(temp) heapq.heappush(A,temp//2+temp%2) print((-sum(A)))
import heapq N,M=list(map(int,input().split())) A=list(map(int,input().split())) A=list([x*(-1) for x in A]) heapq.heapify(A) for i in range(M): temp=heapq.heappop(A) heapq.heappush(A,temp//2+temp%2) print((-sum(A)))
p02912
# -*- coding: utf-8 -*- import sys input = sys.stdin.readline from decimal import Decimal n,m = list(map(int,input().split())) a = list([Decimal(int(x) * (-1)) for x in input().split()]) from heapq import heappush, heappop, heapify heapify(a) for i in range(m): tmp_min = heappop(a)/2 heappush(a,tmp_min) print((sum(list([int(x * (-1)) for x in a]))))
# -*- coding: utf-8 -*- import sys input = sys.stdin.readline n,m = list(map(int,input().split())) a = list([int(x) * (-1) for x in input().split()]) from heapq import heappush, heappop, heapify heapify(a) for i in range(m): tmp_min = (-1)*heappop(a)//2*(-1) heappush(a,tmp_min) print((sum(list([int(x * (-1)) for x in a]))))
p02912
import math n, m = [int(x) for x in input().split()] a = list(map(int, input().split())) for i in range(m): a = sorted(a, reverse=True) a[0] = math.floor(a[0] / 2) print((sum(a)))
import heapq n, m = list(map(int, input().split())) a = list([int(x) * (-1) for x in input().split()]) heapq.heapify(a) for _ in range(m): tmp_min = heapq.heappop(a) heapq.heappush(a, (-1) * (-tmp_min // 2)) print((-sum(a)))
p02912
(n, m) = list(map(int, input().split())) a = sorted(list(map(int, input().split())), reverse = True) while m > 0: found = False for i in range(n-1): if a[i] < a[i+1]: a[i+1] = int(a[i+1] / 2) found = True break if not found: a[0] /= 2 m -= 1 sum = 0 for a_i in a: sum += int(a_i) print(sum)
import math import heapq (n, m) = list(map(int, input().split())) a = [] for a_i in input().split(): heapq.heappush(a, -1 * int(a_i)) for i in range(m): a_i = heapq.heappop(a) heapq.heappush(a, a_i / 2) sum = 0 for a_i in a: sum += int(-1 * a_i) print(sum)
p02912
N,M = list(map(int,input().split())) lis = list(map(int,input().split())) while M > 0: num = lis.index(max(lis)) lis[num] = int(lis[num] / 2) M -= 1 sum = 0 for i in range(len(lis)): sum += lis[i] print(sum)
N,M = list(map(int,input().split())) lis = list([-int(x) for x in input().split()]) import heapq heapq.heapify(lis) for _ in range(M): tmp = -heapq.heappop(lis) tmp //= 2 heapq.heappush(lis,-tmp) print((-sum(lis)))
p02912
N,M = list(map(int,input().split())) L = list(map(int,input().split())) for j in range(M): idx = L.index(max(L)) L[idx] //= 2 print((sum(L)))
import heapq N,M = list(map(int,input().split())) L = list(map(int,input().split())) q=[] for l in L: heapq.heappush(q, -l) for _ in range(M): p = -heapq.heappop(q)//2 heapq.heappush(q, -p) print((-sum(q)))
p02912
'use strict' import math N, M = list(map(int, input().split())) goods_price_list = list(map(int, input().split())) for i in range(M): max_index = goods_price_list.index(max(goods_price_list)) goods_price_list[max_index] = math.floor(goods_price_list[max_index]/2) print((sum(goods_price_list)))
'use strict' import heapq N, M = list(map(int, input().split())) goods_price_list = [-int(_) for _ in input().split()] heapq.heapify(goods_price_list) for i in range(M): heapq.heappush(goods_price_list, -((-heapq.heappop(goods_price_list) // 2))) print((-sum(goods_price_list)))
p02912
n,m=list(map(int,input().split())) a=[int(i) for i in input().split()] for i in range(m): A=max(a) ind=a.index(A) a[ind]=A//2 print((sum(a)))
import heapq n, m = list(map(int, input().split())) a = [int(i) * (-1) for i in input().split()] heapq.heapify(a) for _ in range(m): heapq.heappush(a, heapq.heappop(a) * (-1) // 2 * (-1)) print((-sum(a)))
p02912
import heapq import math #これを加える!!!! def _heappush_max(heap, item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappop_max(heap): """Maxheap version of a heappop.""" lastelt = heap.pop() # raises appropriate IndexError if heap is empty if heap: returnitem = heap[0] heap[0] = lastelt heapq._siftup_max(heap, 0) return returnitem return lastelt """ a = [1,7,3,5,4] #heapify #配列a = [1,7,3,5,4]をheapにする heapq._heapify_max(a) print(a) #[7, 5, 3, 1, 4] #heappop #最大値の取り出し print(_heappop_max(a)) #7 print(a) #[5, 4, 3, 1] #heappush #要素(2)の挿入 _heappush_max(a,2) print(a) #[5, 4, 3, 1, 2] #最大値の取り出し print(_heappop_max(a)) #5 """ N, M = list(map(int, input().split())) a = [int(i) for i in input().split()] b = a[:N] heapq._heapify_max(b) okaiage = [] heapq._heapify_max(okaiage) _heappush_max(okaiage, _heappop_max(b)/2) m = M - 1 for j in range(N-1): temp_oka = _heappop_max(okaiage) temp_a = _heappop_max(b) if m > 0: if temp_a > temp_oka: _heappush_max(okaiage, temp_a/2) _heappush_max(okaiage, temp_oka) else: _heappush_max(okaiage, temp_a) _heappush_max(okaiage, temp_oka/2) else: _heappush_max(okaiage, temp_a) _heappush_max(okaiage, temp_oka) m -= 1 if m > 0: for i in range(m): temp_oka = _heappop_max(okaiage) / 2 _heappush_max(okaiage, temp_oka) okaiage_kiri = [int(math.floor(_heappop_max(okaiage))) for i in range(N)] print((sum(okaiage_kiri)))
import heapq import math #これを加える!!!! def _heappush_max(heap, item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappop_max(heap): """Maxheap version of a heappop.""" lastelt = heap.pop() # raises appropriate IndexError if heap is empty if heap: returnitem = heap[0] heap[0] = lastelt heapq._siftup_max(heap, 0) return returnitem return lastelt """ a = [1,7,3,5,4] #heapify #配列a = [1,7,3,5,4]をheapにする heapq._heapify_max(a) print(a) #[7, 5, 3, 1, 4] #heappop #最大値の取り出し print(_heappop_max(a)) #7 print(a) #[5, 4, 3, 1] #heappush #要素(2)の挿入 _heappush_max(a,2) print(a) #[5, 4, 3, 1, 2] #最大値の取り出し print(_heappop_max(a)) #5 """ N, M = list(map(int, input().split())) a = [int(i) for i in input().split()] heapq._heapify_max(a) for j in range(M): _heappush_max(a, _heappop_max(a)//2) print((sum(a)))
p02912
import heapq import math #これを加える!!!! def _heappush_max(heap, item): heap.append(item) heapq._siftdown_max(heap, 0, len(heap)-1) def _heappop_max(heap): """Maxheap version of a heappop.""" lastelt = heap.pop() # raises appropriate IndexError if heap is empty if heap: returnitem = heap[0] heap[0] = lastelt heapq._siftup_max(heap, 0) return returnitem return lastelt """ a = [1,7,3,5,4] #heapify #配列a = [1,7,3,5,4]をheapにする heapq._heapify_max(a) print(a) #[7, 5, 3, 1, 4] #heappop #最大値の取り出し print(_heappop_max(a)) #7 print(a) #[5, 4, 3, 1] #heappush #要素(2)の挿入 _heappush_max(a,2) print(a) #[5, 4, 3, 1, 2] #最大値の取り出し print(_heappop_max(a)) #5 """ N, M = list(map(int, input().split())) a = [int(i) for i in input().split()] heapq._heapify_max(a) for j in range(M): _heappush_max(a, _heappop_max(a)//2) print((sum(a)))
import heapq n, m = list(map(int, input().split())) a = list([int(x)*(-1) for x in input().split()]) heapq.heapify(a) # aを優先度付きキューに for _ in range(m): tmp_min = heapq.heappop(a) heapq.heappush(a, (-1)*(-tmp_min//2)) # 計算誤差の関係で-1を2回かけてます print((-sum(a)))
p02912
import heapq n,m=list(map(int,input().split())) x=list(map(int,input().split())) x.sort(reverse=True) heapq.heapify(x) ans=0 for i in range(m): y=heapq.nlargest(1,x)[0] x.remove(y) x.append(y//2) for j in range(n): ans+=x[j] print(ans)
import heapq n,m=list(map(int,input().split())) x=list(map(int,input().split())) for k in range(n): x[k]-=2*x[k] heapq.heapify(x) ans=0 for i in range(m): maxvalue=heapq.heappop(x)*(-1) heapq.heappush(x,(maxvalue//2)*(-1)) ans=-1*sum(x) print(ans)
p02912
import bisect N,M = list(map(int,input().split())) A = list(map(int,input().split())) A.sort() for i in range(M): B = A.pop() bisect.insort_right(A,B//2) print((sum(A)))
N,M = list(map(int,input().split())) A = list([int(x)*(-1) for x in input().split()]) import heapq heapq.heapify(A) for i in range(M): B = heapq.heappop(A) heapq.heappush(A,-1*((-B)//2)) print((-sum(A)))
p02912
from heapq import* n,m,*a=[-int(i)for i in open(0).read().split()] heapify(a) while m:heappush(a,0--heappop(a)//2);m+=1 print((-sum(a)))
def main(): from heapq import heapify,heappush,heappop n,m,*a=[-int(i)for i in open(0).read().split()] heapify(a) for _ in range(-m):heappush(a,0--heappop(a)//2) print((-sum(a))) main()
p02912
n, m = list(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() print((sum(a)))
n, m = list(map(int, input().split())) a = list(map(int, input().split())) if n == 1: for i in range(m): a[0] = a[0] // 2 print((sum(a))) exit() a.sort() i = 0 while i < m: a[n-1] = a[n-1] // 2 i+=1 num = len([1 for x in a[:n-1] if x > a[n-1]]) hoge = min(m-i, num) for j in range(hoge): a[n-2-j] = a[n-2-j] // 2 i += hoge a.sort() print((sum(a)))
p02912
#S = input() N,M = list(map(int,input().split())) A_list = list(map(int,input().split())) #X1_list = [int(input()) for i in range(N)] #X2_list = [list(map(int,input().split())) for i in range(N)] for i in range(M): A_list.sort(reverse=True) A_list[0] = A_list[0]//2 print((sum(A_list)))
from heapq import heappush, heappop,heapify N,M = list(map(int,input().split())) A_list = list([-int(a) for a in input().split()]) #print(A_list) heapify(A_list) #print(-heappop(A_list)) for i in range(M): tmp = -heappop(A_list)//2 heappush(A_list,-tmp) print((-sum(A_list))) ''' 3 3 8 6 5 4 4 8 7 6 5 10 6 10 7 6 5 8 9 10 11 12 13 '''
p02912
N,M=list(map(int,input().split())) A=sorted(list(map(float,input().split())),reverse=True) for i in range(M): A[0]=A[0]/2 A=sorted(A,reverse=True) A=[int(a) for a in A] print((sum(A)))
import heapq N,M=list(map(int,input().split())) hq=list(map(float,input().split())) hq=[-n for n in hq] heapq.heapify(hq) for i in range(M): heapq.heappush(hq,heapq.heappop(hq)/2) hq=[int(a) for a in hq] print((-sum(hq)))
p02912
N, M = list(map(int, input().split())) A = list(map(int, input().split())) for i in range(M): A = sorted(A) A[-1] = A[-1] // 2 print((sum(A)))
import heapq N, M = list(map(int, input().split())) A = list(map(int, input().split())) for i in range(len(A)): A[i] *= -1 heapq.heapify(A) for _ in range(M): x = heapq.heappop(A) heapq.heappush(A, (-x//2)*(-1)) print((-sum(A)))
p02912
n, m = list(map(int, input().split())) a_list = list(map(int, input().split())) a_list.sort(reverse=True) swapped = False while m > 0: a_list[0] = a_list[0] // 2 m -= 1 if (n > 1) and (a_list[0] < a_list[1]) and not swapped: temp = a_list[0] a_list[0] = a_list[1] a_list[1] = temp swapped = True else: a_list.sort(reverse=True) swapped = False cost_sum = 0 for a in a_list: cost_sum += a print(cost_sum)
from heapq import heappush, heappop n, m = list(map(int, input().split())) a_list = list(map(int, input().split())) hqueue = [] for a in a_list: heappush(hqueue, -a) for i in range(m): max_item = -(-heappop(hqueue) // 2) heappush(hqueue, max_item) cost = 0 for i in range(n): cost += -heappop(hqueue) print(cost)
p02912