- 采药
- 2009-08-12 15:21:20 @
program cc3;
var
a,b:array[0..1000] of longint;
f:array[0..1000,0..1000] of longint;
t,m,i,j,k,s:longint;
begin
readln(t,m);
for i:=1 to m do
readln(a[i],b[i]);
fillchar(f,sizeof(f),0);
for i:=1 to m do
for j:=a to t do
begin
if (j>=a[i])and(f
1 条评论
-
ooklin LV 8 @ 2014-10-31 23:05:13
var
t,m,i,j:longint;
a,b,p:array[1..1000] of longint;
begin
read(t,m);
for i:=1 to m do
read(b[i],p[i]);
for i:=1 to m do
for j:=t downto b[i] do
if a[j]<a[j-b[i]]+p[i] then
a[j]:=a[j-b[i]]+p[i];
write(a[t]);
end.
- 1