Question: Need help of dynamic programming rod cutting using prigramming language of c++!! to implement thanks !! this is the verifier.cpp #include using namespace std; int

Need help of dynamic programming rod cutting

using prigramming language of c++!! to implement thanks !!

Need help of dynamic programming rod cutting using prigramming language of c++!!

this is the verifier.cpp

#include

using namespace std;

int main(int argc,char **argv) {

// Get the size of the sequence int n = 1; int* p;

cin >> n;

p = new int[n+1]; //read p; p[0] = 0; for(int i=1; i> p[i]; }

// for(int i=1; i

int total_length = 0; int total_revenue = 0;

int student_claimed_revenue = 0; int length = 0;

cin >> student_claimed_revenue; do{ cin >> length; if(length > 0) { total_length += length; total_revenue += p[length]; } }while(length >0);

//cout > optimal_revenue;

if (student_claimed_revenue != total_revenue || total_revenue != optimal_revenue) cout

// Free allocated space delete[] p;

return 1; }

Dynamic Programming: Rod Cutting Description In this assignment you are asked to implement a dynamic programming algorithm for the Rod Cutting Problem (chapter 15.) In the Rod Cutting problem, you are given an integer n 1, along with a sequence of positive prices, pi, p2, ...Pa, where pi is the market price of rod of length i. The goal is to figure out a best way of cutting the given rod of length n to generate the maximum revenue. You can assume that the given prices pi, p2, Pa are all integers. Input The input has the following format. The input starts with n. Then, pi.p2.Pa follow one per each line. Output In the first line, output the maximu revenue (r), followed by an enter key. In the second line, sequentially output the length of each piece in your optimal cutting, and output 1 followed by a space key; separate two adjacent numbers by a space key. Examples of input and Input output 10 Outpuf 18 1 6-1 The following is the output with white characters shown 18 (enter) 1 (space)6(space)-1(enter) Alternatively, the second line can be replaced with "61-1, "2 23-1, "2 3 2 -1", or "3 2 2 -1". That is, any sequence of piece lengths giving the maximum revenue will be considered to be correct

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!