diff --git a/2558. Take Gifts From the Richest Pile b/2558. Take Gifts From the Richest Pile new file mode 100644 index 0000000..f3bf3da --- /dev/null +++ b/2558. Take Gifts From the Richest Pile @@ -0,0 +1,27 @@ +class Solution { +public: +#define P pair + vector getFinalState(vector& nums, int k, int multiplier) { + priority_queue,greater

>pq; + vectorans(nums.size(),0); + for(int i = 0;i0){ + auto n = pq.top(); + pq.pop(); + n.first*=multiplier; + pq.push({n.first,n.second}); + k--; + } + + while(!pq.empty()){ + auto n = pq.top(); + int idx= n.second; + int ele= n.first; + ans[idx]=ele; + pq.pop(); + } + return ans; + } +};