You are viewing a single comment's thread. Return to all comments →
priority_queue<int , vector<int> , greater<int>> pq; for(int i = 0 ; i <A.size() ;i++) { pq.push(A[i]); } int ct =0; while (!pq.empty()) { if(pq.top() >= k) { break; } if(pq.size() <2) { ct = -1; break; } int first = pq.top(); pq.pop(); int second = pq.top(); pq.pop(); int sweetness = first + (2 * second); pq.push(sweetness); ct++; } return ct;``
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 →