200 条题解

  • 0
    @ 2009-07-11 10:41:56

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var

    i,j,k,m,n,x,s:longint;

    f:array[0..100000] of boolean;

    a,b:array[0..102] of integer;

    g:array[0..102,0..100000] of boolean;

    procedure print(n,m:integer);

    begin

    if n>0 then

    if g[n,m] then begin

    print(n-1,m-a[n]);

    b[n]:=1;//write(n);

    end

    else print(n-1,m);

    end;

    begin

    readln(m);

    readln(n);

    fillchar(g,sizeof(g),false);

    fillchar(f,sizeof(f),false);

    fillchar(b,sizeof(b),0);

    for i:=1 to n do begin

    readln(a[i]);

    inc(s,a[i]);

    end;

    {for i:=1 to n-1 do

    for j:=1 to n-1 do

    if a[j]>a[j+1] then

    begin

    a[0]:=a[i];

    a[i]:=a;

    a:=a[0];

    end; }

    f[0]:=true;

    x:=0;

    for i:=1 to n do

    begin

    inc(x,a[i]);

    if x>m then x:=m;

    for j:=x downto a[i] do

    begin

    if f[j] and (j=m) and (f[j-a[i]]) then begin writeln(-1);halt; end;

    if f[j-a[i]] then

    begin

    f[j]:=true;

    g:=true;

    end;

    end;

    end;

    if f[m] then begin print(n,m);

    for i:=1 to n do

    if b[i]=0 then begin write(i); break; end;

    for j:=i+1 to n do

    if b[j]=0 then write(' ',j);

    writeln;

    end

    else writeln(0);

    end.

    哈哈哈哈哈哈

  • 0
    @ 2009-06-13 16:47:28

    第一遍,一维的数组开到1000——>70分;

    第二遍,记录路径的数组开到50——>80分;

    第三遍,我狠了狠心,给记录路径的数组多开了一点点——>100分;

    以后可得狠心啊,朝最极限的开!

    哥哥的通过率!

  • 0
    @ 2009-06-11 19:49:42

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

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

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

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

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

    ├ 测试数据 06:运行超时...

    ├ 测试数据 07:运行超时...

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

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

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

    program p_1071;

    var f:array[0..100000] of boolean;

    w,a,ans,tof:array[0..100] of longint;

    n,i,j,k,m,tolw,tol,cal:longint;

    pan:boolean;

    procedure dfs(y,x,z:longint);

    var l:longint;

    begin

    if pan and (y=0) then

    begin

    writeln(-1);

    halt;

    end;

    if y=0 then

    begin

    pan:=true;

    cal:=z-1;

    for l:=1 to z-1 do

    ans[l]:=a[l];

    exit;

    end;

    for l:=x to n do

    if f[y-w[l]] then

    begin

    a[z]:=l;

    dfs(y-w[l],l+1,z+1);

    end;

    end;

    begin

    readln(tolw);

    readln(n);

    for i:=1 to n do

    begin

    readln(w[i]);

    tof[i]:=tof+w[i];

    end;

    tol:=tof[n]-tolw;

    f[0]:=true;

    for i:=1 to n do

    begin

    if tof[i]>tol then

    k:=tol

    else k:=tof[i];

    for j:=k downto w[i] do

    if f[j-w[i]] then

    f[j]:=true;

    end;

    if f[tol] then

    dfs(tol,1,1);

    if cal=0 then

    writeln(0)

    else

    for i:=1 to cal do

    begin

    write(ans[i]);

    if i

  • 0
    @ 2009-05-31 16:26:28

    可以用一个数组记录上一个编号,再直接用m减

  • 0
    @ 2009-09-18 13:25:16

    F表示当重量为I时的方案数。

    题解 http://254117343.blog.163.com/

  • 0
    @ 2009-05-15 18:04:05

    编译通过...

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

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

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

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

    ├ 测试数据 05:答案错误...程序输出比正确答案长

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

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

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

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

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

    谁有第5组数据?

  • 0
    @ 2009-05-08 20:06:05

    program p1071;

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

    lu:array[0..10000,1..105] of boolean;

    i,j,n,m,v,k:integer;

    begin

    readln(n,m);

    for i:=1 to m do

    begin

    readln(v);

    for j:=n-v downto 0 do

    if f[j+v]1 then begin writeln(-1); halt; end;

    for i:=1 to m do

    if not lu[n,i] then write(i,' ');

    end.

  • 0
    @ 2009-04-25 16:27:38

    编译通过...

    ├ 测试数据 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-04-12 20:01:29

    谁有第四组的数据啊????

    就是那个标准输出

    3 6

    的那个

  • 0
    @ 2009-04-12 12:25:48

    注意数据类型

    用longint即可

    别用integer

  • 0
    @ 2009-04-02 20:54:56

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

    {

    if(DP[j]!=0)

    {

    DP[j+a[i]]++;

    if(DP[j+a[i]]==1)

    {

    H[j+a[i]]=j;

    Q[j+a[i]]=i;

    }

    }

    }

    }

  • 0
    @ 2009-04-02 20:34:44

    灵异事件....

       填充TW会第四个点过不了

      只好填充丢失的

  • 0
    @ 2009-03-17 13:10:35

    var

    f,wh:array[0..100000] of int64;

    a:array[0..100] of int64;

    tw,tot,ans:int64;

    n,i,j:longint;

    begin

    readln(tw);

    readln(n);

    for i:=1 to n do

    begin

    readln(a[i]);

    inc(tot,a[i]);

    end;

    f[0]:=1;ans:=tot-tw;

    for i:=n downto 1 do

    for j:=tot downto a[i] do

    if f[j-a[i]]0 then

    begin

    inc(f[j],f[j-a[i]]);

    if wh[j]=0 then wh[j]:=i;

    end;

    if f[ans]>1 then writeln(-1);

    if f[ans]=0 then writeln(f[tw]);

    if f[ans]=1 then

    while ans0 do

    begin

    write(wh[ans],' ');

    dec(ans,a[wh[ans]]);

    end;

    end.

  • 0
    @ 2009-06-12 18:09:42

    第四组卡了。90分。唉

  • 0
    @ 2009-03-12 19:47:56

    ORZ BT数据

    第4个点……

  • 0
    @ 2009-03-08 15:27:56

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    数组要0..100000 还有longint 我 在第九点卡半天了...

  • 0
    @ 2009-02-21 09:41:39

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    改成int64就全过了

    感谢 永恒の灵魂 的猥琐数据

    第五个点超maxlongint

    错第四个点的

    4

    3

    2

    3

    1

    应该输出1而不是-1

  • 0
    @ 2009-02-20 13:25:38

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    program p1071(input,output);

    var

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

    a,s:array[1..100]of longint;

    f,g,h:array[0..100000]of longint;

    begin

    readln(t);

    readln(n);

    for i:=1 to n do begin readln(a[i]); inc(m,a[i]); end;

    m:=m-t;

    if m1 then writeln('-1');

    if f[m]=1 then for i:=j downto 1 do write(s[i],' ');

    end.

    13:26 2009-2-20

  • 0
    @ 2009-01-05 17:24:54

    太郁闷了

    第一次交最后输出的时候打错了变量

    结果竟然还得了70分

    看来数据中输出0和-1的不少啊

    可惜没有一次AC...

    粗心啊..

  • 0
    @ 2008-12-31 15:41:30

    路径记录?

    使用【1..1000000】的集合过了

信息

ID
1071
难度
7
分类
动态规划 | 背包 点击显示
标签
递交数
6284
已通过
1436
通过率
23%
被复制
13
上传者