commit 7bf19b0fc7433773da4f2992fe4591a781a63b4a
parent 5a4fc68ffcfbea836515b38a1dc3c28b3eb2485c
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Thu, 12 Dec 2024 14:43:31 +0100
Daily Problem
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Problems/2558.cpp b/Problems/2558.cpp
@@ -0,0 +1,15 @@
+class Solution {
+ public:
+ long long pickGifts(const vector<int> &gifts, int k) const {
+ priority_queue<int> pq(begin(gifts), end(gifts));
+ long long remain = accumulate(begin(gifts), end(gifts), 0ll);
+
+ while (k--) {
+ const int crnt = pq.top(), leave = sqrt(crnt);
+ pq.pop(), pq.push(leave);
+ remain -= crnt - leave;
+ }
+
+ return remain;
+ }
+};
diff --git a/README.md b/README.md
@@ -1352,6 +1352,7 @@ reference and a base for solving problems.
| 2545 | Medium | [Sort the Students by Their Kth Score](Problems/2545.cpp) |
| 2551 | Hard | [Put Marbles in Bags](Problems/2551.cpp) |
| 2554 | Medium | [Maximum Number of Integers to Choose From a Range I](Problems/2554.cpp) |
+| 2558 | Easy | [Take Gifts From the Richest Pile](Problems/2558.cpp) |
| 2559 | Medium | [Count Vowel Strings in Ranges](Problems/2559.cpp) |
| 2563 | Medium | [Count the Number of Fair Pairs](Problems/2563.cpp) |
| 2568 | Medium | [Minimum Impossible OR](Problems/2568.cpp) |