using System.Diagnostics;
public static void Main()
var watch = new Stopwatch();
var prices = new[] { 1, 5, 8, 9, 10, 17, 17, 20, 23, 25, 27, 35, 41, 45, 47, 49, 50, 52, 53};
var size = prices.Length;
Console.WriteLine("Maximum Obtainable Value is " + RodCutting.Cut(prices, size));
Console.WriteLine(watch.Elapsed);
public static int Cut(int[] prices, int n)
var maxVal = int.MinValue;
for (var i = 0; i < n; i++)
maxVal = Math.Max(maxVal, prices[i] + Cut(prices, n - i - 1));