vj1317 开心的金明

Vj1317 开心的金明

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //±ÉÈ˵ķ½·¨ / //01±³°ü const maxm=25; maxn=30000; var n,m:integer; v,p:array[0..maxm] of integer; f:array[0..maxn] of longint; function max(x,y:longint):longint; begin if x>=y then exit(x); exit(y); end; procedure init; var i:integer; begin readln(n,m); for i:=1 to m do readln(v[i],p[i]); end; procedure main; var i,j:integer; begin for i:=1 to m do for j:=n downto v[i] do f[j]:=max(f[j],f[j-v[i]]+v[i]*p[i]); end; procedure print; begin writeln(f[n]); end; begin init; main; print; end. ...
View Full Document

Ask a homework question - tutors are online