Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

Help in dp problem
Difference between en1 and en2, changed 94 character(s)
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

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English electro177 2021-06-15 14:53:27 94
en1 English electro177 2021-06-15 14:51:21 616 Initial revision (published)