Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set Min[i] equal to Infinity for all of i
- Min[0]=0
- // Solution 1
- For i = 1 to S
- For j = 0 to N - 1
- If (Vj<=i AND Min[i-Vj]+1<Min[i])
- Then Min[i]=Min[i-Vj]+1
- // Solution 2
- For i = 1 to S
- For j = 0 to N - 1
- If(Min[i+j] > Min[i] + 1)
- Then Min[i+j] = Min[i] + 1
- Output Min[S]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement