We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Data Structures
- Heap
- Jesse and Cookies
- Discussions
Jesse and Cookies
Jesse and Cookies
Sort by
recency
|
351 Discussions
|
Please Login in order to post a comment
def cookies(k,A): # convert list A to priority queue heapq heapq.heapify(A)
def cookies(k, A): A.sort(reverse = True) queue = [] mixes = 0 while True: if len(A) <= 1 and queue: A = queue[::-1] + A queue = [] if not A and not queue: return mixes if queue: if A[-1] <= queue[0]: last_num = A.pop() else: last_num = queue.pop(0) else: last_num = A.pop() if last_num >= k: next elif len(A) == 0 and last_num < k: return -1 else: if not queue: sec_num = A.pop() else: if A[-1] <= queue[0]: sec_num = A.pop() else: sec_num = queue.pop(0) new_num = last_num + 2 * sec_num queue.append(new_num) mixes += 1
Is it a good idea to use it for my content based website of cookieclickerunblocked, I'm running this website on WordPress right now, Please give me a honest advice. Thanks
C# Solution!