[Question]
  [
Given a rod of length n inches and a list of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces. For example, if length of the rod is 8 and the values of different pieces are given as following, then the maximum obtainable value is 22 (by cutting in two pieces of lengths 2 and 6)
```
length   | 1   2   3   4   5   6   7   8  
-------------------------------------------
price    | 1   5   8   9  10  17  17  20
```
And if the prices are as following, then the maximum obtainable value is 24 (by cutting in eight pieces of length 1)
```
length   | 1   2   3   4   5   6   7   8  
--------------------------------------------
price    | 3   5   8   9  10  17  17  20
```
The input will be given in this form:
The prices will be in ascending order, index starting at 1 to n separated by a space.
`{price of length 1} {price of length 2}.... {price of length N}`
The output should be the maximum Obtainable Value
`{maxVal}`
a Non-Golfed solution to this, in Python is:
```
INT_MIN = -32767
def cutRod(price, n): 
    val = [0 for x in range(n+1)] 
    val[0] = 0
    for i in range(1, n+1): 
        max_val = INT_MIN 
        for j in range(i): 
             max_val = max(max_val, price[j] + val[i-j-1]) 
        val[i] = max_val 
  
    return val[n] 
  
arr = [1,2,3,4,5,6,7,8,9,10] 
size = len(arr) 
print(cutRod(arr, size))
```
Test cases:
```
|                                      Input                                     | Output |
|:------------------------------------------------------------------------------:|:------:|
|                              `1 5 8 9 10 17 17 20`                             |  `22`  |
|                                `1 3 2 5 6 7 4 8`                               |  `12`  |
|                     `5 6 3 2 4 6 8 7 3 4 6 2 12 4 5 7 4 3`                     |  `90`  |
| `23 2 3 45 34 23 3143 13 13 213 1321 3123 12 312 312 31 3 213 432 41 3 123 43` | `9475` |
```
  
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 7 bytes
```
LŒṗịµ§Ṁ
L        length
 Œṗ      integer partitions
   ị     index
     §Ṁ  sum each and take the maximum
```
My first jelly answer, so there can probably be improvements made.
[Try it online!](https://tio.run/##y0rNyan8/9/n6KSHO6c/3N19aOuh5Q93Nvz//z/ayFjHSMdYx8RUx9hEB8gxNjQx1jEEIyMwZWQIFANKGBqBaCjWgciaGBvpmIA4IAUmxrEA "Jelly – Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 57 bytes
```
a=>a.map((v,i)=>a[i]=w=a.map(u=>v=(u+=a[--i])>v?u:v)|v)|w
```
[Try it online!](https://tio.run/##rZNNb4JAEIbv/Iq5uSgfLgtVaRZPPfTUQ4/WZAlFuw0CkQVNxN9uZ1Ga9NDioZslsx8zzzvZvHzGTVwle1kqOy/e08uGX2Iexc4uLglpLGniZiXX/MCvZzWPGk7qCY9Xti3XZtQs67AxW5yHi0orlcRVChw2dZ4oWeRATDiBOzZauGs852Wt7sps4aVWOrk12tD@1xH2wLAd6ltQCGAOC6BToDM9vakY6BuE52FOO/wmSGfgocIDzMCHuRh8Eyz5iy00SiN9jHOEsm7lAdVHQafCxK/sxfTGFp6GYHEAzAfcMOozoN30uuBh6xQvEMy@P7je@gzV9EYn@KiHwIU/C3BhjF04O6p4VXuZb4npYNxhqMpMKjJ6y0e4zmSSEmaBTc1Hozedsyn2T3HyQTKZowMjOBlZqmAltaMsSI9lmqg1WlPfo5cVprrCGS@Fu0WMzi2uhkL3kq7qpkQ7pb4FwA70n3DUGpOjibVJkVdFljpZsSU9g3OYXDV/UKybCFad8bt8AQ "JavaScript (Node.js) – Try It Online")
As the question is a [knapsack problem](https://en.wikipedia.org/wiki/Knapsack_problem). Let \$ val\left[i\right] \$ be the price of segment of length \$i\$. We have:
$$ dp\left[0\right] = 0$$
$$ dp\left[i\right] = \max\_{j=1..i} \left\{ val\left[j\right] + dp\left[i-j\right] \right\} $$
And \$dp\left[len\right]\$ is the answer.
To golf more bytes, we slightly modify the transition equation into $$ dp\left[i\right] = \max\left\{val\left[i\right], \max\_{j=1..i-1} \left\{ dp\left[j\right] + dp\left[i-j\right] \right\} \right\} $$
We use \$a\$ for both \$val\$ and \$dp\$ during iteration. When try to calculate \$a\left[i\right]\$, all values \$a\left[0..i-1\right]\$ equals to \$dp\$ and all other values equals to \$val\$. Also, our array is 0-indexed instead of 1-indexed. So we modify the equation into
$$ a\left[i\right] = \max\left\{a\left[i\right], \max\_{j=0..i-1} \left\{ a\left[j\right] + a\left[i-j-1\right] \right\} \right\} $$
Use the feature that when access values out of array range, `undefined` is returned. And mathematics operation on `undefined` results `NaN`. `NaN>v` will also be `false`. We can ignore \$j=0..i-1\$ part from \$\max\$. And the code is shown above.
Ungolfed C program as reference:
```
int f(int* a) {
  int i, j, val;
  // before loop: a[i] = price of length (i+1) segement
  // after loop: a[i] = max sum price of cutted length (i+1) segment
  for (i = 0; a[i]; i++) {
    // before loop j
    // a[i] = price of length (i+1) segment
    //      = price if do not cut the segment
    for (j = 0; j < i; j++) {
      // price when cut the segment into two parts with length (j+1), (i-j)
      val = a[j] + a[i - j - 1];
      // we prefer higher price if we can
      if (a[i] < val) {
        a[i] = val;
      }
    } // j
  } // i
  return a[i - 1];
}
```
[Try it online!](https://tio.run/##hVPbcpswEH3vV5xJJjNQyw0YkqbB7Y@4flBAGDG25MFy3ZkM357uShDl8lBmdGH37NnDkaiXu7p@udam3p8bhfXJNdp@6369aOPQJjR/hUzx/AXgiBboBf7IfUWB21s8qdYOCntrj4@QG73FTxwHXSvYFntldq5Dohd5ipPaqYMyLtTJ1qnhfdlB/sXpfIjl9dk51XximUioL8WoLqs8QwW9WAShH5Whn4P/Uzhxe6x/Zqxu0VgY61gVXKfeob2WPmjpsYamJYrxbIHm0inzkYF9tXAXi6Mc3AkXTYpmYT0JE6Rv2acTF3lPjeSm32LB34MltVwi31ax2UVRP9WSw53edbS8fgRlamkmJL0n3pE1s0a5mH2azpmf0a8js7ObfqNpMyh3HswkhEWM/uYcpDZJvDZms93kWcacockzcoE7gQeBHwJ5RuN7GKsMo4iYgiIeeS9A2ZJKYj6EA6T0@wePKuZXiuchdzeXF7F8FSoZTemCkhwp8pLmfBqrsFmxlJzTzFe8mUJ/RpUFtwoBD2WezDs3Vq83lg883BRNvpfztZ2dn@ymAzOuTa5umt/mStCPaOhE0pRpxuh6xnb/Aw "C (gcc) – Try It Online")
Above C code may golf to [81 bytes](https://tio.run/##TVFtT4MwEP7Or7jMuFBbTEuZzhT8I9gPBIaWaGeQ8YXhX8c7umWS3Ovz3HNw1Ml7XS@LE50YTRs7PzxUbGqPfeyKrpCmS5LzuSq7gnNnTVU6m4/bbUxJMTI2FohZjiX/7ayh0iXKmnm5c77@PDUHyH@Gxh0fP16jCNXhq3I@ZjBFAFT60pZKSgvF2gKYQAnYCdgLeBGgJNpzsFTCLG4cjZ2V@SQA0QxHbnhoB0q25vuVpa8l9lXAdtdxfRtPwySxEdYIUkerDL26WBqSlF5FEUx6@p8L@4mVaVoVGiuVdPBrcNts0OG5gU4PDs8gDYYcMgyc46Hg8kQhfPdIbOPNffPmNwLa2OOvYIxkSK8/DKfeo0g0R8sf), but still longer than JavaScript implementation. :(
---
* -5 bytes thanks to [Arnauld](https://codegolf.stackexchange.com/users/58563/arnauld)
[Answer]
# JavaScript (ES6), 78 bytes
*Saved 1 byte thanks to @Davide*
```
a=>(m=F=(n,i=0,s=0)=>n?i>n||F(n+~i,i,s+a[i])|F(n,i+1,s):m=s<m?m:s)(a.length)&m
```
[Try it online!](https://tio.run/##bY3NisIwFIX3PsiQ0KM0P9Uqpu58CXERtGqkSYeJuJJ59XpvBTcKN9yf852Tq7/7fPgLv7dp6o/tcHKDd42IbutEQnAlsiula9ImNOnx2IpU/AcE5MLvwl7yAaFQyHIVXV7HTVxlKfysa9P5dpE/cTj0KfddO@v6sziJnUKFGkuoEmrBpcu9lJMPykATOccCFvUXgjVmLPWaKDNOGopP1WgzX2yaPcRWMBa0GGUN1Fh6bJq@ViRQjnk/vFRrKJwXBizHD08 "JavaScript (Node.js) – Try It Online")
### Commented
```
a => (              // a[] = input array
  m =               // initialize m to a non-numeric value
  F = (             // F is a recursive function taking:
    n,              //   n = integer to be partitioned
    i = 0,          //   i = integer to be subtracted from n (-1)
    s = 0           //   s = price sum
  ) =>              //
    n ?             // if n is not equal to 0:
      i > n         //   abort if i is greater than n
      ||            //   otherwise:
        F(          //     first recursive call with:
          n + ~i,   //       n - i - 1
          i,        //       i unchanged
          s + a[i]  //       s + i-th price
        ) |         //
        F(          //     second recursive call with:
          n,        //       n unchanged
          i + 1,    //       i + 1
          s         //       s unchanged
        )           //
    :               // else:
      m = s < m ? m //   update m to max(m, s)
                : s //
)(a.length)         // initial call to F with n = length of a[]
& m                 // return m
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~98~~ 89 bytes
-9 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat)
```
m;*n;l;g(N,L)int*N;{n=N;l=L;f(0,m=0);}f(t,s,i){m<t?m=t:0;for(i=0;++i<l-s;f(t+n[i],s+i));}
```
[Try it online!](https://tio.run/##ZZDhbsIgEMe/@xTEZQnYc6GAU0e7vYDxBbQflmodSYtLi5@aPnt3h4tdMgIc3P/HHXfl8lKW45PzZX07nVnWhZO7vny9j41deFvbC9/DTjgfFnvb@3xv63xnKy6hyaWwQ8UDdOBE32Tho8nDm7TVteUulzZJXFYvO4RD4g@ugC5xAp@MGIw1n85zwfrZjOEgjz@Y4qBMwXL0kjNuvYQUVrCBLaR4XNNUcoBJ1KAQeIU1GNhMArlIMmg3KOp4UpCSaxVpPdGKUERWoA1ddGo0pHGqaBQmSlHA5/qx4K4ajTHpQoDRQww62KkIKq8@U4FU3JZq2YIyf5HYNMQcEtKiyZhBkyTitxsPksaFx4ZSTFcI@x/4bjFYxefPp6OfA2uQuf9qytiew631mGw2jD8 "C (gcc) – Try It Online")
### Explanation
That's the explanation of a previous [illegal version](https://tio.run/##ZZDdToQwEIXveYpmjQnIrCltccGCPghyYfjRJtA1wF4Rnh1nioKJTcu053xMO1OdP6pqvTO26m51w7Jxqs318fNl7XXrW@hggjEwdnqweu6z6bXPp2eu2@vgo8hMznUYmqw7j794aAtTwhiaINDLSlD/bqwfsNnzGA5SbKHKQqiS5aiS6D4zhwhiSCCFCLcXmoIvcJgSBAJPcAEFyWGQRJbCmKAp3U5ARFLsaHnQglBEYpCKDjJSEiI3hQsCL4rQwN/lvmBzlcScdCBAycUlXfRRBJXXNVQgFZdSLSkI9RfZm4cE1xgypjCEYfDTjZ10tO8aSjkxcOCB/g99DZiw9U/39Zs9AeuR2b1@u2Z76fGKoZlug0XHW9Zv "C (gcc) – Try It Online"), but not so much has changed, so the explanation is still valid.
The function `f()` call itself recursively and into a loop, so that for each index of the loop it starts a whole new loop, and for each index of this other loop it launches a whole new loop and so on.
Each branch stops when the sum of the lengths of the pieces of that particular branch reaches the length of the rod.
Every time, before to enter a new branch-generating loop, the current maximum value possible is compared with that of the branch and eventually updated to a greater value.
```
m;             // variable used to store the maximum value possible
f(            // this is a recursive function creating all the possible combinations of the pieces
n,            // it takes: an array of integers
l,             // the length of the array
t,            // the total price of the current branch
s)             // the sum of the inches virtually sold till now
int*n;{                            
    m<t?m=t:0;    // if the maximum value is less than the total of a branch, update it
    for(int i=0;  // `i` represents the inches of a particular piece
    ++i<l-s;      // untill `i` is less than the maximum length minus the current sum of the inches
      f(         // f() calls itself with:
      n,         // the same array
      l,          // the same length
      t+n[i],     // the current total price plus the price of this one more piece
      s+i)        // the current sum of the inches plus the length of this one more piece
    );            // end of for() loop
}                // end of function
```
[Ported to JavaScript](https://codegolf.stackexchange.com/a/218622/100356)
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 33 bytes
```
Max[Range@#~FrobeniusSolve~#.#2]&
```
[Try it online!](https://tio.run/##PYxPC4JAEMXvfo0FT1O4O2vaofDUqSDyKB42Wf9ArmAWgehXtxmDYIaZ93tvpjVDbVszNIVZysNyMZ/sZlxlEzGf@u5uXfN6pt3jbWexFSr3l2vfuCETm2OZna2rhjoRIPLcn9PCuHn0RgkhxLAHGYCMuFQwAWMERdYOItAQM2LBUNOMCeO6KZCMwjWHnFMcIjME1EACpUaQa6l1KHouyaBD/Df8XI30jQUHNE7etHwB "Wolfram Language (Mathematica) – Try It Online")
Input the length and list of prices.
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 51 bytes
```
f=lambda l,n:n and max(x+f(l,n:=n-1)for x in l[:n])
```
[Try it online!](https://tio.run/##hVHNboMwDL7zFL6RaKnU/HS0ldiLMDQxCGo1mkbAJDbEszM7KVJvOziyvx87cfzPeLk7ffT9urZ5V90@mwo64c4OKtfArZrY9NIyQnK3k7y99zDB1UFXnF3J19EO44fvr7UdIAeWABRSwEHAUcBJgNxjZDHUvhTE63949KNEBdWrAGQMyiMXoUibkB@DQm8l4jJyh82qo1VFFymR0kgQoqXBUz5CxUTRFSTR1Es/HXE2qYymMREIUkNzeGInb@vRNrQNhRJlYpcTvvRksgNP6outv2xPgvT9W2WmTgWETOqUJ7RhLyzt@Pfq2dOCBWzN@RlfBOCwR2cd8zyU9AMt88LFEk1uZG06@0XA7BbYvcE8LDA/LlDYPB/KJeXrHw "Python 3.8 (pre-release) – Try It Online")
Same length:
**51 bytes**
```
f=lambda l,n:max([0]+[x+f(l,n:=n-1)for x in l[:n]])
```
[Try it online!](https://tio.run/##hVHNboMwDL7zFL6RqKnU/DBoJfYiDE0dDSoqTSNgEhvi2ZlNitTbDo7s78dOHP8zXB9OZ75bljpvz/evyxla4U7388iKQ7krxl3NCMjdXvL60cEIjYO2OLmy5Mtg@@HTd01le8iBRQCFFJAIyAQcBcgDRhpCHUpBvP6HRz9K1Kp6E4CMQXngAhRos@bZqtBbibgMXLJZdbCq4CIlUhoJQrQ0eMpnqJAouoIkmnrplyPMJpXRNCYAq9TQHB7Z0dtqsBfahkKJMqHLEV96NGnCo@pqq5vtSBB/fKvUVLGANZM65hGt2AtLS/5tPHtZsICtOT/hiwAc9mitY56vJf1AzbxwoUSTG1gdT34WMLkZ9u8w9TNMzwsUNs/7co758gc "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~82~~ 79 bytes
```
(n,m=0)=>(g=(t,s,i=0)=>{m<t?m=t:0;while(i<n.length-s)g(t+n[i],s-~i++);})(0,0)|m
```
[Try it online!](https://tio.run/##bY3djsIgFITv90kgnRr@utZV1gcxXhitFdPSjRC9cPXV6wETbzQ55DDMN8Nxc96E7cn9xdIPu2bc25F59FZw@8tayyICXFbXfhGXvY0/Yn45uK5hbuEnXePbeCgDb1ks/MqtEcq7Kwo@v3EmIPh/P24HH4aumXRDy/ZsJVGhxgxSQE7TKLHm/OuN0lBEfmMKg/oDkbzEGNo1UTrfFGR6qnJMf4iplCG2gjYgoaXRkHlUXoq@lmRQj34dPF2jqTyJBJhUPz4A "JavaScript (Node.js) – Try It Online")
### That's my first JavaScript answer!!
Made translating [my C answer](https://codegolf.stackexchange.com/a/218559/100356). The algorithm is the same (you can read the explanation from there if interested).
[Answer]
# [Wenyan Language](https://wy-lang.org), 2178 bytes
I know what you're going to say -- **WHAT ON EARTH IS THIS?!**
```
吾有一術名之曰「獲取」欲行是術必先得一物曰「對象」一物曰「域」乃行是術曰乃得對象[域]是謂「獲取」之術也吾有一術名之曰「賦值」欲行是術必先得一物曰「對象」一物曰「域」一物曰「值」乃行是術曰乃得對象[域]=值是謂「賦值」之術也減零以三萬二千七百六十七名之曰「極小」吾有一術名之曰「分桿」欲行是術必先得一物曰「物價」一物曰「桿數」乃行是術曰吾有一列名之曰「遞歸」昔之「索引」者今零是矣恆為是吾有一爻名之曰「甲丙」若「索引」不大於「桿數」者昔之「甲丙」者今陽是矣云云若「甲丙」等於零者乃止云云充「遞歸」以零加「索引」以一昔之「索引」者今其是矣云云昔之「索引」者今一是矣恆為是加「桿數」以一吾有一爻名之曰「甲申」若「索引」小於其者昔之「甲申」者今陽是矣云云若「甲申」等於零者乃止云云吾有一物曰「極小」名之曰「最大」昔之「索引其二」者今零是矣恆為是吾有一爻名之曰「亥卯」若「索引其二」小於「索引」者昔之「亥卯」者今陽是矣云云若「亥卯」等於零者乃止云云吾有一術名之曰「丁戊」欲行是術必先得一物曰「a」一物曰「b」乃行是術曰乃得Math.max(a,b)是謂「丁戊」之術也施「獲取」於「物價」於「索引其二」名之曰「子甲」減「索引」以「索引其二」夫「遞歸」之其加「子甲」以其名之曰「午申」施「丁戊」於「最大」於「午申」昔之「最大」者今其是矣加「索引其二」以一昔之「索引其二」者今其是矣云云施「賦值」於「遞歸」於「索引」於「最大」噫加「索引」以一昔之「索引」者今其是矣云云施「獲取」於「遞歸」於「桿數」。名之曰「支子」乃得 「支子」是謂「分桿」之術也噫吾有一列名之曰「桿長」吾有一數名之曰「桿數」夫「桿長」之長昔之「桿數」者今其是矣施「分桿」於「桿長」於「桿數」名之曰「卯地」吾有一物曰「卯地」書之
```
Expect an input at char 678:
```
...
吾有一列名之曰「桿長」(INPUT GOES HERE!)吾有一數
...
```
Using the format:
```
充「桿長」以(some number)以(some number)以(some number)以......
```
Well I know it's difficult for those who don't understand Chinese. Fortunately the language compiles into equivalent JavaScript. I'll show it below for you to understand:
```
var 獲取 = () => 0
獲取 = function(對象) {
  return function(域) {
    return 對象[域]
  }
}
var 賦值 = () => 0
賦值 = function(對象) {
  return function(域) {
    return function(值) {
      return (對象[域] = 值)
    }
  }
}
// Notice that functions above are only for convenience, because all function calls in this language is curry.
var 極小 = 0 - 32767
// The main function
var 分桿 = () => 0
分桿 = function(物價) {
  return function(桿數) {
    // The above two lines is to make the function a curry.
    var 遞歸 = []
    索引 = 0
    while (true) {
      // In this language we only have while-loops, but we can use 'if' and 'break' to control it.
      var 甲丙 = false
      if (索引 <= 杆數) {
        甲丙 = true
      }
      if (甲丙 == 0) {
        break
      }
      遞歸.push(0)
      索引 = 索引 + 1
    }
    索引 = 1
    while (true) {
      var 甲申 = false
      if (索引 < 杆數 + 1) {
        甲申 = true
      }
      if (甲申 == 0) {
        break
      }
      var 最大 = 極小
      索引其二 = 0
      while (true) {
        var 亥卯 = false
        if (索引其二 < 索引) {
          亥卯 = true
        }
        if (亥卯 == 0) {
          break
        }
        var 丁戊 = () => 0
        丁戊 = function(a) {
          return function(b) {
            return Math.max(a, b)
          }
        }
        var 子甲 = 獲取(物價)(索引其二)
        var _ans5 = 索引 - 索引其二
        var _ans6 = 遞歸[_ans5 - 1]
        var _ans7 = 子甲 + _ans6
        var 午申 = _ans7
        最大 = 丁戊(最大)(午申)
        索引其二 = 索引其二 + 1
      }
      var _ans10 = 賦值(遞歸)(索引)(最大)
      索引 = 索引 + 1
    }
    var 支子 = 獲取(遞歸)(杆數)
    return 支子
  }
}
var 桿長 = []
// There should be some input...
杆數 = 桿長.length
var 卯地 = 分桿()
console.log(卯地) // Program complete
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 7 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
gÅœ<èOà
```
[Try it online](https://tio.run/##yy9OTMpM/f8//XDr0ck2h1f4H17w/3@0oY6pjoWOpY6hgY6hOQgZGcQCAA) or [verify all test cases](https://tio.run/##PY5BCgIxDEWvMsz6L5qmdSoIs3HvAYYuFERcuRCEOYAeQC/g0nsUL@JF6k8FISXJ@79JTuft7rivl3nsu8/t3vXjvK6Hcn0/VuW1Kc@KOk2CiIQlxEEGC@8ySBWeygIDAhKJ1cYCcyLVVnmIodhsSps3D7UIDWCjEhTSwrfkOVoo8J/@H35qUA6zxgxB2x2tddwgttUucSQRLucv).
**Explanation:**
```
g        # Get the length of the (implicit) input-list
 Åœ      # Get all lists of positive integers that sum to this length
   <     # Decrease each by 1 to make it a 0-based index
    è    # Index those into the (implicit) input-list
     O   # Sum each inner list
      à  # Pop and push the maximum
         # (after which it is output implicitly as result)
```
[Try it online with step-by-step output.](https://tio.run/##NY9NSgMxFMf3nuIxK4UIHUH8QCkFNwWhm@7ERTp9nXmaSYZ5b9p6AE/gBVx6Ag@geK7xJWkhgcD/65fAdkU4jsXcd4PcQmHuf76nJ8Uj@loaCBuQBoGOYp3VmXPgiIWjoQtMQtvoEqyxZ41YAR5akKBvYnCpLRb8vv995I4HrHq0jIC2amD1BmXU77I492vcZ0VbQ4ZoO0cVSaY5j/up8StHlvYVky8OK9Yh7LGHo3VxoPdrJbJK/DKwpExr99TmXAbWBJzuGood@suh1ys6e5YmP804PpXm0lybG1NOTHkVz8Xk@R8)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 19 bytes
```
ＦＡ⊞υ⌈⊞ＯＥ⮌υ⁺κ§υλιＩ⊟υ
```
[Try it online!](https://tio.run/##PUs5DsIwEOx5hcu1ZAofVFSIKkWERRulsIJRInLJR5Tfm7WDKHZ2zq43rlvMmNJ7cQSqeY0BKCU6@h4iI7XZhylOkPVjtc6ExUFtVnjazTpvIVJG9Bg9fBi5hWp@2T3vRkoxGBCvJ@2GOcDd@AB6WXGBZkpNIyQjghFEdcGnUCGXXCHy34mDCJ6DHHNR2B/KvrSUREMdRqkq2bbpvI1f "Charcoal – Try It Online") Link is to verbose version of code. Explanation: Based on @tsh's approach.
```
ＦＡ
```
Loop over each input element.
```
⊞υ⌈⊞ＯＥ⮌υ⁺κ§υλι
```
The value of each length is the maximum of the current input element and the array sum of the array of values so far with its reverse. This is pushed to the array of values.
```
Ｉ⊟υ
```
Output the last value.
[Answer]
# [Python 3](https://docs.python.org/3/), 103 bytes
```
lambda p,n:max(map(sum,d(p,n)))
d=lambda p,n:[[p[n-1]]]+[m+[p[i]]for i in range(n-1)for m in d(p,n+~i)]
```
[Try it online!](https://tio.run/##hVJNb4MwDL3zKzztAFFTqRC6fkjsvtMuu1E0UQgragkRpFo7xP46s5NW6m0HB/u95w/Z6Ks5tEpMVbKbTnmzL3PQXG2b/BI0uQ76c8PLABHGmFcmD4o01amah1mWzdJmhkGdZVXbQQ21gi5XXzJAmhHUEGSrzH5rlk1G9uZTd3Uhe0gg8ADSkMOSw5rDhkO4QFs5ixYZJ178w2M@SiKreuGATIxyxznI0bH111Yh7iHioeOW91ThUiOXRUqkBBKEiDDGN7xZ5JyIRgiJplri4XG9SRULauMAK42pD/PkRcvCyJK2EaEkil2VzYLBM37i1ZLBx9s7mLrBnbVnA60Cc5BwynvyJewRqw18t92xJ7K5IqdNq5@84iCLo@youL87R6u48DlYLxQ@8@hCmku60U@tg4fjcLgPxra4DQCFNU5SBZrZkK5X2Z/DhpikTFD5gx45DGqE@SsM/QjDbYBUJkmfjT6b/gA "Python 3 – Try It Online")
Inputs the prices as a list of integers along with the length of the rod.  
Returns the maximum price you can get.
Uses a variation of the integer partition function I wrote for my [Landau logarithm](https://codegolf.stackexchange.com/q/217536/9481) [answer](https://codegolf.stackexchange.com/a/217602/9481).
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 13 bytes
```
eSmsm@Qtkd./l
```
[Try it online!](https://tio.run/##K6gsyfj/PzU4tzjXIbAkO0VPP@f//2gjYx0FIx0FIGliCqRMgDwg29jQBEgaQrERhGFkCJIASRsagVlwAqwfrMrEGChgAhEAKzUxjgUA "Pyth – Try It Online")
The obvious approach: try all integer partitions, compute their value, and take the maximum. I spent a while trying to use the `M` or `L` builtins, but they didn't end up being shorter.
[Answer]
# [Julia 1.0](http://julialang.org/), ~~47~~ 36 bytes
port of [xnor's answer](https://codegolf.stackexchange.com/a/218595/98541)
```
n*l=max(0,(1:n.|>x->l[x]+(n-x)l)...)
```
[Try it online!](https://tio.run/##hVHbboMwDH3nK6wKiaR1EbkwyiT4EYamimYrG8sQUAlN@3fmECr1bQ@O7HOxneTj1rVnMS@L3XfF13lmCTLxbOPfcj6WXTXXB2aPM@94HMd8mcw4vfZD25gRCmABQCUQUoQTQo4gEorMh0xqdLz6hyc/SeSqekIgRpPccx7ytF7z06pQ95Jw4bn0blXeKr3LKYlSRDhECU2n2EL6RLoVhKNdL/Vw@NlOpZUb44FVqt0cHpi5N81kLu41JEmk9l1yummus5QHzdU0n2ZwgujlJjPdRAhrJlTEg7fvAViPhkNr4aft2cMTI9zbc7oSgKUmnbHv05X1HnG/sGcWt5Jsduos24U9hqQuIRxhh7DtUDFTFCM/iJoWt5flDw "Julia 1.0 – Try It Online")
# [Julia 0.4](http://julialang.org/), 42 bytes
or with Julia 1.0+ and Combinatorics.jl
```
f(p,n)=maximum(x->sum(p[x]),partitions(n))
```
[Try it online!](https://tio.run/##hVHbbsIwDH3vV1gIiUTLJHLpoA/lRxiaqhIgG4SoSaVqP985MUi87cGJ7XOO7Tjf49V183xiQXje3rrJ3cYbm953Ea@wnw5chG5ILrm7j8xzPicb01cYXG8jtMAqgL0UUAvYCmgEyDXahkytDyLj@h8c9UhRhfUhABGDdMIoRbAp/rYw9DPEvCSsfko1SRWpMhMhjUDOaGnwlA9T5Kg8gsxwrqVfDuqdWUbnNpQoVJP78MpOwfbJHvM2FFKUoSoNvrQxm5pX/cX2P3bIhNXnqDamXwkontQrXp3uA@D@LQfn4dcF9rJiAc/yHJ8E4LHI1fpzurBAmfwL9H0lRJlPV88WyyCWyN7BMsJCwGOGPbNtG/mbPODg/jj/AQ "Julia 0.4 – Try It Online")
[Answer]
# [Scala](http://www.scala-lang.org/), 98 bytes
Port of [@tsh's Javascript answer](https://codegolf.stackexchange.com/a/218557/110802) in Scala.
---
Golfed version. [Try it online!](https://tio.run/##ZZHBTsMwDIbvfQpzi7UMNU0HY10mceTACXFCO4SuHYlKhrqqCFV99uIkG5pGJTuO/dn@lR5L3ejp8G6rsoNnbRwMSdLrBuoVe2xb/fP25Lqt2pBHUJNWm6HXLRhuea/S4vvDNBXTzOCNSnGwfym7Njj0SjOLMyrP7VxgYeqArnv0h@oLO1NiLEzwnhI4TgC7qoZPksJ0uz@uIMp46Vrj9ltcwaszHSjSCfR5qY5uAWIhBaeL4LDgsOTwwEGkZPfRMopT5NespErouONAVB5ar7lYjmge4mWg5flKeRFri/MY@X9MFif4LsIkQT4jRU5enCyLQealCV/2c@WFizo8lUu/MiYCmoedYSUm4agPLTAD6zm4W@N2pqyOeHpCgC962q5xrGaO/gvGxjHxNk6/)
```
a=>{var i,j,v=0;while(a(i)!=0){j=0;while(j<i){v=a(j)+a(i-j-1);if(a(i)<v)a(i)=v;j+=1};i+=1};a(i-1)}
```
Ungolfed version. Try it online!
```
object Main {
  def f(a: Array[Int]): Int = {
    var i = 0
    var j = 0
    var val_ = 0
    while (a(i) != 0) {
      j = 0
      while (j < i) {
        val_ = a(j) + a(i - j - 1)
        if (a(i) < val_) {
          a(i) = val_
        }
        j += 1
      }
      i += 1
    }
    a(i - 1)
  }
  def main(args: Array[String]): Unit = {
    val n = Array(
      Array(1, 5, 8, 9, 10, 17, 17, 20, 0),
      Array(1, 3, 2, 5, 6, 7, 4, 8, 0),
      Array(5, 6, 3, 2, 4, 6, 8, 7, 3, 4, 6, 2, 12, 4, 5, 7, 4, 3, 0),
      Array(23, 2, 3, 45, 34, 23, 3143, 13, 13, 213, 1321, 3123, 12, 312, 312, 31, 3, 213, 432, 41, 3, 123, 43, 0)
    )
    for (i <- n.indices) {
      println(f(n(i)))
    }
  }
}
```
]