Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mod_rod_cut(p, n, c)
- {
- // Create a new array.
- arr[0..n]
- // first element in the new array is empty.
- arr[0] = 0
- for j = 1 to n
- // if no cuts are made we can just return this value.
- q = p[j]
- for i = 1 to j - 1
- // adjust for the fixed cost of making a cut
- q = max(q, p[i] + arr[j-i] - c)
- r[j] = q
- // return the total revenue
- return r[n]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement