I was doing problem [towers](https://atcoder.jp/contests/dp/tasks/dp_x).I sorted all the blocks according to weight + strength↵
from exchange arguments and then now i did not get idea how to do transitions in dp ,but i saw some code and i thought i should do it by weights from 0 to total weight (but i do not know why) and the transition was↵
↵
↵
~~~~~↵
Your code here...↵
↵
for (auto block : blocks) {↵
int w = block.w, s = block.s; ll v = block.v;↵
for (int i = w + s; i >= w; i--){↵
dp[i] = max(dp[i], dp[i —- w] + v);↵
}↵
~~~~~↵
↵
↵
↵
Please help me how to take the dp state and also the transitions mainly(i did not understand after thinking a lot)↵
Thank you
from exchange arguments and then now i did not get idea how to do transitions in dp ,but i saw some code and i thought i should do it by weights from 0 to total weight (but i do not know why) and the transition was↵
↵
↵
~~~~~↵
Your code here...↵
↵
for (auto block : blocks) {↵
int w = block.w, s = block.s; ll v = block.v;↵
for (int i = w + s; i >= w; i--)
}↵
~~~~~↵
↵
↵
↵
Please help me how to take the dp state and also the transitions mainly(i did not understand after thinking a lot)↵
Thank you