嗯,这题不用深搜或广搜,这题用动态规划o( ̄ヘ ̄o#)
by SSL_lzx @ 2017-08-07 07:09:44
动态归划 呵呵哒
K是价值,C是时间,F[t]是目前最优
```cpp
var t,m,i,v:longint;
f,c,k:array[0..1001] of longint;
function max(a,b:longint):longint;
begin
if a>b then max:=a
else max:=b;
end;
begin
readln(t,m);
for i:=1 to m do
readln(c[i],k[i]);
for i:=1 to m do
for v:=t downto c[i] do
f[v]:=max(f[v],f[v-c[i]]+k[i]);
writeln(f[t]);
end.
自己体会一下动归的魅力吧
```
by AAAking @ 2017-09-10 10:53:51