So I have a problem with DP, as I'm a beginner. Here's my problem, it's like the turtle tower but with some changes, as it has values for each turtle too.
You are given n turtles, and for each turtle you are given its weight (w) its strength (s) and its value(v). The strength of a turtle is the maximal weight you can put on it without cracking its shell. Find the greatest possible value you can get out of turtles, by stacking one on top of the other without cracking any turtle.
I'm having trouble with the recurrence relation, since I'm confused with the fact that I'd have to check whether the sum of weights on top of each turtle is higher than its strength. I mean, I thought about making an array holding the best tower value for each next turtle we add to the tower, but I don't know how I'm going to check whether all the turtles under the new one can hold the new sum of weights with their strength.
The only way I could think about is saving each turtle's strength minus current_sum_of_weights of turtles on top of her. But it seems too complicated.
I guess I would start by sorting turtles based the sum of each one's weight and strength but still I'm having trouble with the recursion.
I don't need to write a code, I just want to write the recurrence relation and prove it.