记录编号 |
20059 |
评测结果 |
WWWWWWWWWW |
题目名称 |
罪犯问题B |
最终得分 |
0 |
用户昵称 |
1102 |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
2.194 s |
提交时间 |
2010-10-20 09:57:16 |
内存使用 |
0.68 MiB |
显示代码纯文本
program xxxx;
var i,n,m,k,j,x:longint;
f:array[1..10000,0..4] of longint;
fx,fy:array[0..50000] of longint;
function max(a,b:longint):longint;
begin
if a>b then
max:=a
else
max:=b;
end;
function min(a,b:longint):longint;
begin
if a>b then
min:=b
else
min:=a;
end;
begin
assign(input,'criminalb.in');
reset(input);
assign(output,'criminalb.out');
rewrite(output);
read(n,m,k);
for i:=1 to n do
begin
read(f[i,0]);
f[i,1]:=0;
f[i,2]:=0;
f[i,3]:=0;
f[i,4]:=0;
end;
for i:=1 to m do
begin
read(x);
if x>0 then
inc(f[x,1])
else
inc(f[-x,2]);
end;
fx[0]:=0;
for i:=1 to k do
for j:=1 to n do
begin
fx[i]:=max(fx[i-1],fx[i]);
if (i-f[j,2]>=0)and(f[j,3]<>1) then
if fx[i-f[j,2]]+f[j,0]>fx[i] then
begin
fx[i]:=fx[i-f[j,2]]+f[j,0];
f[j,3]:=1;
end;
end;
x:=0;
for i:=1 to n do
x:=x+f[i,0];
for i:=0 to k do
fy[i]:=x;
for i:=1 to k do
for j:=1 to n do
begin
fy[i]:=min(fy[i-1],fy[i]);
if (i-f[j,1]>=0)and(f[j,4]<>1) then
if fy[i-f[j,1]]-f[j,0]<fy[i] then
begin
fy[i]:=fy[i-f[j,1]]-f[j,0];
f[j,4]:=1;
end;
end;
writeln(fx[k]);
write(fy[k]);
close(input);
close(output);
end.