- 采药
- 2017-07-16 11:58:10 @
var
i,t,m:integer;
//t:set of 1..1000;
//m:set of 1..100;
time:array[1..100] of integer;
money:array[1..100] of integer;
function max(a,b:integer):longint;
begin
if a>b then max:=a else max:=b;
end;
function opt(m,n:integer):longint;
begin
if (m<=0) or (n<=0) then opt:=0
else
if time[m]>n then
opt:=opt(m-1,n)
else
opt:=max(opt(m-1,n),opt(m-1,n-time[m])+money[m]);
end;
begin
readln(t,m);
for i:=1 to m do
readln(time[i],money[i]);
write(opt(m,t));
end.
0 条评论
目前还没有评论...