From fb8069d0e1b65e6c17f502f2021a97f8741f2c52 Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Mon, 16 Dec 2024 23:44:23 +0530 Subject: [PATCH] Create 2558. Take Gifts From the Richest Pile --- 2558. Take Gifts From the Richest Pile | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2558. Take Gifts From the Richest Pile 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; + } +};