You are not logged in. Please login at www.codechef.com to post your questions!

×

scudiv spoj - getting wrong answer

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&lt;nmax;j++)" {="" dp[i][j]="INF;" }="" }="" dp[0][0]="0;" for(int="" k="1;k&lt;=n;k++)" {="" for(int="" i="omax-1;i">=cyl[k].ovol;i--) { for(int j=nmax-1;j>=cyl[k].nvol;j--) { dp[i][j]=min(dp[i-cyl[k].ovol][j-cyl[k].nvol]+(LL)cyl[k].wt, dp[i][j]); } } } LL ans=INF; for(int i=oneed;i<omax;i++) { for(int j=nneed;j<nmax;j++) { ans=min(ans, dp[i][j]); } } printf("%lld\n", 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[i].ovol, &cyl[i].nvol, &cyl[i].wt); } solve(); } }

asked 23 Mar '15, 21:50

prince0322's gravatar image

3★prince0322
112
accept rate: 0%

edited 23 Mar '15, 21:52

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

(24 Mar '15, 00:27) shivam2174★

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.

link

answered 24 Mar '15, 02:20

sharru05's gravatar image

3★sharru05
5591723
accept rate: 14%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×21

question asked: 23 Mar '15, 21:50

question was seen: 542 times

last updated: 24 Mar '15, 02:20