259 条题解

  • 0
    @ 2009-07-23 23:07:39

    P1313∽01背包P1025≌01背包

  • 0
    @ 2009-07-23 17:31:19

    用to的话,以i=1,f[1]=1,t[1]=2为例,就会

    初始:000000000...

    t=2:020000000...

    t=4:020400000...

    t=6:020406000...

    ...

  • 0
    @ 2009-07-20 23:53:01

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    嘿嘿嘿嘿,保住了通过率的救命题

  • 0
    @ 2009-07-17 18:23:16

    var

    n,tt,i,j,max:longint;

    w,t:array[1..100] of longint;

    f:array[0..1000] of longint;

    Begin

    readln(n);

    readln(tt);

    for i:=1 to n do readln(w[i],t[i]);

    for i:=1 to n do

    begin

    for j:=tt downto t[i] do

    begin

    if f[j]max then max:=f[j];

    end;

    end;

    writeln(max);

    end.

  • 0
    @ 2009-07-16 15:18:13

    本质上就是01背包嘛。。。不过我还是不知道to跟downto的不同不同在哪里。。

  • 0
    @ 2009-07-15 14:45:01

    var i,j,k,l,max,n,o,p,t,s:longint;

    f,en,tim:array [0..10000] of longint;

    begin

    readln(n);

    readln(t);

    for i:=1 to n do

    readln(en[i],tim[i]);

    fillchar(f,sizeof(f),0);

    s:=0;

    max:=0;

    for i:=1 to n do begin

    inc(s,tim[i]);

    if s>t then s:=t;

    for j:=s downto tim[i] do begin

    if f[j-tim[i]]+en[i]>f[j] then f[j]:=f[j-tim[i]]+en[i];

    if f[j]>max then max:=f[j];

    end;

    end;

    writeln(max);

    end.

  • 0
    @ 2009-07-15 14:38:47

    01 背包 的题一共有多少个啊,刷得我都不想刷了

  • 0
    @ 2009-07-09 20:10:32

    #include

    using namespace std;

    int dp[1001][1001]={0};

    int main ()

    {

    int t,i,j,n,cost[1001],f[1001],k,l;

    cin>>n>>t;

    for (i=1;i>f[i]>>cost[i];

    for (i=1;i=1;j--)

    {

    if (j>=cost[i])

    dp[i][j]=max(dp[j],dp[j-cost[i]]+f[i]);

    else

    dp[i][j]=dp[j];

    }

    }

    cout

  • 0
    @ 2009-07-06 16:10:18

    草泥马

    数据不是小于100啊

    郁闷

  • 0
    @ 2009-06-13 16:32:06

    背包

  • 0
    @ 2009-05-27 15:19:34

    背包

  • 0
    @ 2009-05-24 14:49:11

    我想知道VIJOS

    里又多少个一摸一样的01背包

  • 0
    @ 2009-05-22 18:30:16

    PROGRAM p1025;

    const maxn=1001;

    var

    a :array[0..maxn,0..maxn] of longint;

    f :array[0..maxn] of longint;

    i,j,t,m,n,x,y :longint;

    begin

    readln( n ); readln( t );

    for i:=1 to n do

    read( a[ i,1 ], a[ i,2 ] );

    fillchar(f,sizeof(f),0);

    for i:=1 to n do

    for j:=t downto a do

    if a[ i,1 ] + f[ j- a ] > f[ j ] then f[ j ] := a[ i,1 ] + f[

    j-a ];

    writeln(f[t]);

    end.

    倒序(用downto)就能过了

    要是正序的话会出现一个物体在F【i】i小的时候用过了,在i大的时候又用了一次。

    水平有限,大家要多鼓励我。。。

  • 0
    @ 2009-05-22 15:40:29

    const maxn=1001;

    var f:array[0..maxn]of longint;

    i,j,k,n,t,m,x,y:longint;

    begin

    readln(n);

    readln(t);

    for n:=1 to n do begin

    readln(x,y);

    for j:=t downto y do

    if f[j-y]+x>f[j]then

    f[j]:=f[j-y]+x;

    end;

    writeln(f[t]);

    end.

  • 0
    @ 2009-05-16 13:35:26

    var

    i,j,n,t:integer;

    money,time:array [1..1000] of integer;

    f:array[0..1000,0..1000] of integer;

    begin

    readln(n);

    readln(t);

    for i:=1 to n do

    begin

    read(money[i],time[i]);

    readln;

    end;

    fillchar(f,sizeof(f),0);

    for i:=1 to n do

    for j:=1 to t do

    begin

    f:=f;

    if (time[i]

  • 0
    @ 2009-05-09 10:04:36

    惨痛的教训:后读代价!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • 0
    @ 2009-05-01 15:40:31

    好水啊 竟然忘了设初值,害的我提交了两次

  • 0
    @ 2009-04-12 13:28:50

    朴素01背包

  • 0
    @ 2009-03-22 03:45:44

    和采药就差4个字符,即输入相反了。。。。。

    哈哈 我终于会dp啦

  • 0
    @ 2009-03-21 20:46:38

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    对小智有些无语

信息

ID
1025
难度
4
分类
动态规划 | 背包 点击显示
标签
(无)
递交数
9921
已通过
4043
通过率
41%
被复制
14
上传者