commit 9276bc698adfdf18fb16c9902f410e91508bde24
parent 677bb7f7619c3af34b290aeb06db33da24d26e75
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Tue, 18 Jun 2024 13:37:16 +0200
Daily Problem
Diffstat:
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/Problems/0826.cpp b/Problems/0826.cpp
@@ -0,0 +1,23 @@
+class Solution {
+ public:
+ int maxProfitAssignment(const vector<int> &difficulty, const vector<int> &profit,
+ const vector<int> &worker) const {
+ static int profits[100001];
+ const int n = size(profit);
+ int res = 0;
+
+ memset(profits, 0x00, sizeof(profits));
+ for (int i = 0; i < n; i++) {
+ profits[difficulty[i]] = max(profits[difficulty[i]], profit[i]);
+ }
+
+ for (int i = 1; i < 100001; i++) {
+ profits[i] = max(profits[i], profits[i - 1]);
+ }
+
+ for (const int m : worker)
+ res += profits[m];
+
+ return res;
+ }
+};
diff --git a/README.md b/README.md
@@ -514,6 +514,7 @@ for solving problems.
| 0817 | Medium | [Linked List Components](Problems/0817.cpp) |
| 0820 | Medium | [Short Encoding of Words](Problems/0820.cpp) |
| 0823 | Medium | [Binary Trees With Factors](Problems/0823.cpp) |
+| 0826 | Medium | [Most Profit Assigning Work](Problems/0826.cpp) |
| 0830 | Medium | [Kth Smallest Element in a BST](Problems/0230.cpp) |
| 0833 | Medium | [Find And Replace in String](Problems/0833.cpp) |
| 0834 | Hard | [Sum of Distances in Tree](Problems/0834.cpp) |