Basketball Exercise
MediumRating 1400Codeforces2-D Dynamic Programming
Approach hintTry it first, then revealHide
Track three states per column: the best total if the last pick is from row 1, from row 2, or if nobody is picked in this column. Each state draws only from the previous column, so the scan is O(n).