dp
with a single entry {0: 0}
.r
in rods
.dp
called new_dp
to store the updated states.(diff, taller)
pair in dp
, update new_dp
with three possible states:
dp
to new_dp
.r
to the taller stand: new_dp[diff + r] = max(new_dp.get(diff + r, 0), taller + r)
.r
to the shorter stand: new_diff = abs(diff - r)
and new_taller = max(taller, diff + r)
; then new_dp[new_diff] = max(new_dp.get(new_diff, 0), new_taller)
.new_dp
back to dp
.dp[0]
as the maximum height of the billboard with equal height stands.