if you have n points to cut and a wooden log of lenght l,choose mid[l]
and choose a point which is closer to this l and do this for all
segments
On Jan 31, 10:14 am, ritu wrote:
> You are given a wooden log of length n. It has n+1 grooves marked on
> it from 0 to n. You are given an array contai
vector > cuts(int n, vector A)
{
int min;
int numcuts = A.size();
vector > Cuts(vector V(0,n), n);
vector > Result(vector V(0,n), n);
for(int i=0;i wrote:
> sorry ..the complete question is
>
>
> You are given a wooden log of length n. It has n+1 grooves marked on
> it from 0 to n. You
sorry ..the complete question is
You are given a wooden log of length n. It has n+1 grooves marked on
it from 0 to n. You are given an array containing numbers within the
range of 1 to n-1. These elements of the array represents the points
on the log at which u need to cut the wooden log. Now the
You have given a nice setup, but you haven't stated a problem or asked
a question.
On Jan 31, 12:14 pm, ritu wrote:
> You are given a wooden log of length n. It has n+1 grooves marked on
> it from 0 to n. You are given an array containing numbers within the
> range of 1 to n-1. These elements of
DP solution is ..
c[i][j] = min (c[i][k] + c[k][j] + (a[j]-a[i])) where j>i & k=i+1 to
j-1
c[i][j] = a[j]-a[i] when j=i+1
c[i][j] indicates the minimum cost to cut the log starting at a[i] and
ending at a[j]...
c[0][n] gives the answer..
correct me if i am wrong or any better solutions?
--
Yo
DP solution is ..
c[i][j] = min (c[i][k] + c[k][j] + (a[j]-a[i])) where k=i+1 to j-1
c[i][j] = a[j]-a[i] when j=i+1
c[i][j] indicates the minimum cost to cut the log starting at a[i] and
ending at a[j]...
c[0][n] gives the answer..
correct me if i am wrong or any better solutions?
--
You rece