begin
readln(t,m);
for i:=1 to m do
begin readln(a,b);
for tt:=t-a downto 0 do if v[tt+a]<v[tt]+b then v[tt+a]:=v[tt]+b;
end;
a:=0;for i:=t downto 1 do if v[i]>max then max:=v[i];writeln(a);
end.
你的程序循环结束后只要写上writeln(v[t]);就可以了,因为容量最大时价值一定最大
結果100分的題改剩30……
超時。。
var
p:array[0..1000] of longint;
a,b,n,m,i,j:longint;
readln(n,m);
read(a,b);
for j:=n downto a do
if p[j-a]+b>p[j] then p[j]:=p[j-a]+b;
write(p[n]);
快速帮助 | 运行状态 | 反馈举报 | 关于我们 | 免责声明 | 浙ICP备11060257号 Processed in 0.0037 Second(s) Copyright (C) RQNOJ 2007-2019. All Rights Reserved.