scudiv spoj - getting wrong answer


#1

please help why this code wrong answer on spoj …
#include<bits/stdc++.h>
using namespace std;

#define omax 23
#define nmax 81
#define INF 1000000003

typedef long long LL;

struct cylinder
{
int ovol;
int nvol;
int wt;
}cyl[1002];

LL dp[omax][nmax];
int oneed, nneed, n;

void solve()
{
for(int i=0;i<omax;i++)
{
for(int j=0;j<nmax;j++)
{
dp*[j]=INF;
}
}
dp[0][0]=0;
for(int k=1;k<=n;k++)
{
for(int i=omax-1;i>=cyl[k].ovol;i–)
{
for(int j=nmax-1;j>=cyl[k].nvol;j–)
{
dp*[j]=min(dp[i-cyl[k].ovol][j-cyl[k].nvol]+(LL)cyl[k].wt, dp*[j]);
}
}
}
LL ans=INF;
for(int i=oneed;i<omax;i++)
{
for(int j=nneed;j<nmax;j++)
{
ans=min(ans, dp*[j]);
}
}
printf("%lld
", ans);
}

int main()
{
int test;
scanf("%d", &test);
while(test–)
{
scanf("%d %d", &oneed, &nneed);
scanf("%d", &n);
for(int i=1;i<=n;i++)
{
scanf("%d %d %d", &cyl*.ovol, &cyl*.nvol, &cyl*.wt);
}
solve();
}
}


#2

Try this, 1 2 2 2 1 1 1 2 2 50
The answer should be 50. You are not getting this…I hope this will help you.


#3

post the ideone link and please explain your algorithm and also write comments so that it will be easy to debug