vj1334 NASA&ccedil;š„&eacute;&pound;Ÿ&ccedil;‰&copy;&egrave;&reg;&iexcl;&aring;ˆ’

# Vj1334 NASA&ccedil;š„&eacute;&pound;Ÿ&ccedil;‰&copy;&egrave;&reg;&iexcl;&aring;ˆ’

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: const maxn=50; maxv=400; var n,m,vinteger; a,b,carray[0..maxn] of integer; farray[0..maxv,0..maxv] of longint; function max(x,ylongint)longint; begin if x=y then exit(x) else exit(y); end; procedure init; var iinteger; begin readln(v,m); readln(n); for i=1 to n do readln(a[i],b[i],c[i]); end; procedure main; var i,j,kinteger; begin fillchar(f,sizeof(f),0); for i=1 to n do for j=v downto a[i] do for k=m downto b[i] do f[j,k]=max(f[j,k],f[j-a[i],k-b[i]]+c[i]); end; procedure print; begin writeln(f[v,m]); end; begin init; main; print; end. ...
View Full Document

## This note was uploaded on 02/21/2011 for the course CS 001 taught by Professor 001 during the Spring '11 term at Shandong University.

Ask a homework question - tutors are online