Open In App

GATE | GATE CS 2021 | Set 1 | Question 50

Like Article
Like
Save
Share
Report

Define Rn to be the maximum amount earned by cutting a rod of length n meters into one or more pieces of integer length and selling them. For i>0, let p[i] denote the selling price of a rod whose length is i meters. Consider the array of prices:

p[1]=1, p[2]=5, p[3]=8, p[4]=9, p[5]=10, p[6]=17, p[7]=18 

Which of the following statements is/are correct about R7?
(A) R7=18
(B) R7=19
(C) R7 is achieved by three different solutions
(D) R7 cannot be achieved by a solution consisting of three pieces


Answer: (A) (C)

Explanation: According to given data,

Number of pieces Possible max profits with combination of rod size 
7 7 (1, 1, 1, 1, 1, 1, 1)
6 10 (2, 1, 1, 1, 1, 1)
5 13 (2, 2, 1, 1, 1)
4 16 (2, 2, 2, 1)
3 18 (2, 2, 3)
2 18 (6, 1)
1 18 (7)

Therefore,

Option (A) and (C) are correct.

Refer – Cutting a Rod | DP-13, and solution – https://ide.geeksforgeeks.org/lbBeyHa3xd


Quiz of this Question


Last Updated : 24 May, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads