1059

var
i,j,k,l,n,m,x:longint;
a,b,c:array[1..1000000] of longint;
f:array[0..1000000] of boolean;
begin
assign(input,'1059.in'); reset(input);
assign(output,'1059.out'); rewrite(output);
readln(n);
for i:=1 to n do
begin
l:=0;
read(x);
f[0]:=true;
while x<>-1 do
begin
for j:=0 to l do begin if f[j]=true then f[j+x]:=true; end;
l:=l+x;
read(x);
end;
for j:=1 to l do if f[j]=true then inc(a[j]);
fillchar(f,sizeof(f),false);
end;
for i:=10000 downto 1 do
if a[i]=n then begin writeln(i); halt; end;
writeln(0);
close(input);
close(output);
end.
哪错了,求帮助

1 条评论

  • 1

信息

ID
1059
难度
6
分类
动态规划 | 背包 点击显示
标签
(无)
递交数
7828
已通过
2342
通过率
30%
被复制
19
上传者