Math, asked by bhuvanesh1159, 1 year ago

Cut all the rods with some length such that the sum of cut-off length is maximized. So there are n rods of different lengths. The task is to cut all the rods with some maximum integer height h such that sum of cut-off lengths of the rod is maximized and must be greater than m.

Answers

Answered by mridahingmire
0

Answer:


Step-by-step explanation:

Input: N = 7, M = 8, a[] = {1, 2, 3, 5, 4, 7, 6}

Output: 3

Rod 1 and 2 are untouched, and rod 3, 4, 5, 6, 7 are cut with the cut-off lengths being (3-3) + (4-3) + (5-3) + (7-3) + (6-3) which is equal to 10 which is greater than M = 8.


Input: N = 4, M = 2, a[] = {1, 2, 3, 3}

Output: 2

Similar questions