/ Vijos / 讨论 / 采药 /

这是怎么回事呢?大家帮帮忙。

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 条评论

  • @ 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

信息

ID
1104
难度
4
分类
动态规划 | 背包 点击显示
标签
递交数
16859
已通过
6541
通过率
39%
被复制
39
上传者