dp[i][w] = max( skip dp[i-1][w] , take v[i] + dp[i-1][w - w[i]] ). Watch each cell choose take vs skip, then trace the reconstruction path back from dp[n][W].
junior.md and professional.md for the take-or-skip recurrence and its optimal-substructure proof.