Skip to content

Commit a99a72d

Browse files
committed
Runtime: 1491 ms (Top 12.85%) | Memory: 85.2 MB (Top 46.18%)
1 parent 3ca3a87 commit a99a72d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/algorithms/M/Maximum Total Beauty of the Gardens/Maximum Total Beauty of the Gardens.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Runtime: 1491 ms (Top 12.85%) | Memory: 85.2 MB (Top 46.18%)
2+
13
class Solution {
24
public:
35
long long maximumBeauty(vector<int>& flowers, long long newFlowers, int target, int full, int partial) {
@@ -21,7 +23,7 @@ class Solution {
2123
flowers.pop_back();
2224
}
2325
long long beautyForFullCase = (long long)(n - i) * full; // All the elements from i to n -1 are incremented till target, so they have a beauty of (n - 1) * full
24-
26+
2527
// Here, we do binary search on x, which is the the maximum number we can increment all the numbers from 0 to i - 1 to. The maximum we can increment to is target-1 because after that, "partial" will not be applicable. Binary search is done to find out the maximum possible answer for the partial case.
2628
int l = 0, r = target - 1;
2729
long long beautyForPartialCase = 0;
@@ -46,4 +48,4 @@ class Solution {
4648
}
4749
return ans;
4850
}
49-
};
51+
};

0 commit comments

Comments
 (0)