Help in a Dp problem

Правка en1, от practicener, 2020-10-29 18:07:38

I am referring to ->https://codeforces.me/contest/1012/problem/C I could come up with O(n^3) solution-> Let dp[i][j]= minimum cost to build j houses in the first i hills. We iterate over the continuous segments, at the end points of which , we build the houses. That is -> if we are considering a segment 1...........i we can break it as 1......k-1 [ k..........i] However this will not fit in the constraints. The editorial is a bit too hard to understand. Can someone please suggest some way to reduce the complexity to O(n^2) . Thank you

Теги dp, div1

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский practicener 2020-10-29 18:07:38 573 Initial revision (published)