hi everyone i am trying to solve a question . the question goes like this ↵
↵
you have given an array you have to maximize the cost factor of array and cost can be calculated in following way ↵
↵
COST = A*a[i]-B*a[j]+C*a[k]+D*a[l]+E*a[m] where i<j<k<l<m ↵
↵
now you have given A,B,C,D,E , maximize the cost of given array↵
↵
sample test case ↵
n= 5↵
↵
array = { 10 17 15 6 17}↵
↵
A=8, B=5, C=4, D=6, E=9↵
↵
↵
Output is 172 ↵
↵
..............................................................................↵
↵
MY approach is simple i make a dp[n][4] and dp[i][0] calculate the max of A*a[i] till i , dp[j][1] calculate the max of A*a[i]-B*a[j] and so on ..↵
↵
you have given an array you have to maximize the cost factor of array and cost can be calculated in following way ↵
↵
COST = A*a[i]-B*a[j]+C*a[k]+D*a[l]+E*a[m] where i<j<k<l<m ↵
↵
now you have given A,B,C,D,E , maximize the cost of given array↵
↵
sample test case ↵
n= 5↵
↵
array = { 10 17 15 6 17}↵
↵
A=8, B=5, C=4, D=6, E=9↵
↵
↵
Output is 172 ↵
↵
..............................................................................↵
↵
MY approach is simple i make a dp[n][4] and dp[i][0] calculate the max of A*a[i] till i , dp[j][1] calculate the max of A*a[i]-B*a[j] and so on ..↵