MEMOIZED-CUT-ROD (P. MEMOIZED-CUT-ROD-AUX(p.n.r) 1 let r[0..n]be a new array 1 ifru≥0 2 fori = Oton 2 return rn] 3 r)=-o 3 ifn==0 return MEMOIZED-CUT-ROD-AUX(p.n.r) 4 9=0 5 else q=-oo 6 fori I ton 7 q max(g,p[i]MEMOIZED-CUT-ROD-AUX (p.n-i.r)) 8 rin]=q BOTTOM-UP-CUT-ROD(P. 1 let r[0..n]be a new array 2 r[O1=0 复杂度均降 3 forj=Ito n 4 到平方级! q=-0∞ 5 fori Ito j 6 q max(g.pli]+rlj-i]) 7 ru]=q 8 return rn]复杂度均降 到平方级!