Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. Set Min[i] equal to Infinity for all of i
  2. Min[0]=0
  3.  
  4. // Solution 1
  5. For i = 1 to S
  6. For j = 0 to N - 1
  7. If (Vj<=i AND Min[i-Vj]+1<Min[i])
  8. Then Min[i]=Min[i-Vj]+1
  9.  
  10. // Solution 2
  11. For i = 1 to S
  12. For j = 0 to N - 1
  13. If(Min[i+j] > Min[i] + 1)
  14. Then Min[i+j] = Min[i] + 1
  15.  
  16. Output Min[S]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement