Dynamic Programming21 sections · 916 units
Open in Course

Tall Barn - Convexity

Why diminishing returns

Let g(k)g(k) = minimum total time using kk cows. Claim: gg is convex, meaning each additional cow helps less than the previous one. Intuition: with few cows, adding one makes a big difference. One cow per floor means total time equals ai\sum a_i. Adding a second cow to the busiest floor cuts that floor's time in half. Huge improvement.

With many cows, they're already well-distributed. Adding one more barely changes anything. This diminishing returns property, g(k1)g(k)g(k)g(k+1)g(k-1) - g(k) \geq g(k) - g(k+1), is exactly convexity (each additional unit helps less than the previous). The Aliens Trick applies.