You are viewing a single comment's thread. Return to all comments →
For those who use nowadays editor that already handles the input and output, the code is:
def cookies(k, A): from heapq import heappop,heappush,heapify heapify(A) fC = 0 try: while A[0] < k: fC+=1 c1 = heappop(A) c2 = heappop(A) newCookie=(1*c1)+(2*c2) heappush(A,newCookie) return fC except: return -1
Seems like cookies are disabled on this browser, please enable them to open this website
Jesse and Cookies
You are viewing a single comment's thread. Return to all comments →
For those who use nowadays editor that already handles the input and output, the code is: