You are viewing a single comment's thread. Return to all comments →
int cookies(int k, vector<int> A) { priority_queue<int, vector<int>, greater<int> > pq; for(int i : A)pq.push(i); int ans = 0; int temp = pq.top(); pq.pop(); while(temp < k){ if(pq.empty()) return -1; int secTemp = pq.top(); pq.pop(); pq.push(temp+2*secTemp); temp = pq.top(); pq.pop(); ans++; } return ans ; }``
Jesse and Cookies
You are viewing a single comment's thread. Return to all comments →