Hi,
Can u please explain. I couldn't get what do u mean by after processing K
bundles?
I wrote following code (which is inefficient) which is goving correct result
for 140. But how to get the value 1400.
#include<iostream>
using namespace std;
//#define MAX 0x7FFFFFFF
int main()
{
int weight[] = {8, 20, 70, 130};
int cost[] = {1025, 325, 475, 1050};
int ans[100000];
for (int i=1; i< 10000; i++)
ans[i] = 21474836;
ans[0] = 0;
int i;
cout << ans[1250] << endl;
for (i=1; i<100000; i++)
{
for (int j=0; j<4; j++)
{
if((i-weight[j]) >= 0)
{
int cos = ans[i-weight[j]] + cost[j];
if (cos < ans[i])
{
ans[i] = cos;
// cout << ans[i] << " " <<i<<endl;
}
}
}
if (i>=140 && ans[i] < INT_MAX)
break;
}
cout << ans[i] << " " << i <<endl;
return 0;
}
Regards,
Akash Agrawal
http://tech-queries.blogspot.com/
On Thu, Dec 30, 2010 at 6:03 PM, juver++ <[email protected]> wrote:
> DP[K][N] - minimal cost choosing N balls and after processing K bundles.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.