diff --git a/solutions/silver/usaco-990.mdx b/solutions/silver/usaco-990.mdx
index 7530a1bca5..fbf1d07cfe 100644
--- a/solutions/silver/usaco-990.mdx
+++ b/solutions/silver/usaco-990.mdx
@@ -2,14 +2,12 @@
id: usaco-990
source: USACO Silver 2020 January
title: Berry Picking
-author: Qi Wang, Daniel Suh, Juheon Rhee
+author: Qi Wang, Daniel Suh, Juheon Rhee, David Guo
---
-Let's say Bessie and Elsie get the same number of berries.
-What's a case that give us this?
-How can we increase this value?
+What if you fixed the number of berries $b$ in each bucket? How would you allocate the berries to maximize the number of buckets filled with exactly $b$ berries? How would you fill the remaining buckets that cannot be filled with exactly $b$ berries?
@@ -17,6 +15,29 @@ How can we increase this value?
[Official Analysis (C++)](http://www.usaco.org/current/data/sol_berries_silver_jan20.html)
+## Explanation
+
+Let $b$ represent the minimum number of berries in any bucket that Elsie receives.
+We can assume WLOG that all of Elsie's buckets contain exactly $b$ berries,
+as any configuration where Elsie's buckets are unequal can be adjusted to make all buckets contain exactly $b$,
+preserving or improving the minimum value $b$.
+
+Our goal is to maximize the total number of berries placed into $K$ buckets,
+each containing at most $b$ berries, such that at least $\frac{K}{2}$ buckets contain exactly $b$ berries.
+
+Now, consider the allocation of berries from a single tree in the optimal solution.
+There is no benefit to creating multiple buckets with fewer than $b$ berries from the same tree.
+Therefore, apart from at most one bucket, all other buckets filled with berries from this tree will contain exactly $b$ berries.
+
+The optimal approach is to repeatedly fill buckets with exactly $b$ berries until either all $K$ buckets are filled
+or the tree no longer has at least $b$ berries remaining.
+If there are still buckets to fill after this, sort the remaining trees by the value $B_i$ $mod$ $b$,
+where $B_i$ is the number of berries on tree $i$.
+hen, iterate through the trees in descending order of $B_i$ $mod$ $b$,
+filling the remaining buckets as efficiently as possible.
+
+This process can be repeated for each possible value of $b$ from $1$ to $\max(B_i)$.
+
## Implementation 1
**Time Complexity:** $\mathcal{O}(max(B_i) \cdot N\log N)$
@@ -28,16 +49,7 @@ How can we increase this value?
#include
using namespace std;
-typedef long long ll;
-typedef long double ld;
-
-#define mpa make_pair
-#define pb push_back
-#define ins insert
-#define f first
-#define s second
#define all(x) x.begin(), x.end()
-#define nl "\n"
void fileIO(string filename) {
freopen((filename + ".in").c_str(), "r", stdin);
@@ -81,7 +93,7 @@ void solve() {
for (int j = 0; j < N && j + amount < K; j++) { cur += A[j] % i; }
mx = max(mx, cur);
}
- cout << mx << nl;
+ cout << mx << "\n";
}
int main() {