commit 2208abd0e42780a715f544192b54af01f2d529ff
parent 264bd7f5022c3452ae13dbb2c0de44ce960affd9
Author: Dimitrije Dobrota <mail@dimitrijedobrota.com>
Date: Wed, 21 Feb 2024 11:55:28 +0000
1 Random Problem
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/Problems/1954.cpp b/Problems/1954.cpp
@@ -0,0 +1,15 @@
+class Solution {
+ public:
+ long long minimumPerimeter(const long long neededApples) const {
+ long long low = 1, high = 100000;
+ while (low < high) {
+ const long long mid = (low + high) / 2;
+ const long long count = 4 * mid * mid * mid + 6 * mid * mid + 2 * mid;
+ if (count >= neededApples)
+ high = mid;
+ else
+ low = mid + 1;
+ }
+ return low * 8;
+ }
+};
diff --git a/README.md b/README.md
@@ -940,6 +940,7 @@ for solving problems.
| 1930 | Medium | [Unique Length-3 Palindromic Subsequences](Problems/1930.cpp) |
| 1934 | Medium | [Confirmation Rate](Problems/1934.cpp) |
| 1947 | Medium | [Maximum Compatibility Score Sum](Problems/1947.cpp) |
+| 1954 | Medium | [Minimum Garden Perimeter to Collect Enough Apples](Problems/1954.cpp) |
| 1962 | Medium | [Remove Stones to Minimize the Total](Problems/1962.cpp) |
| 1963 | Medium | [Minimum Number of Swaps to Make the String Balanced](Problems/1963.cpp) |
| 1964 | Hard | [Find the Longest Valid Obstacle Course at Each Position](Problems/1964.cpp) |