×

# include<bits stdc++.h="">

using namespace std;

# 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(); } }

112
accept rate: 0%

(24 Mar '15, 00:27)

 0 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. answered 24 Mar '15, 02:20 3★sharru05 559●1●7●23 accept rate: 14%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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: 543 times

last updated: 24 Mar '15, 02:20