比赛 |
10.10.18noip模拟 |
评测结果 |
WWWAWWWWTT |
题目名称 |
罪犯问题B |
最终得分 |
10 |
用户昵称 |
wo shi 刘畅 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-10-18 19:50:56 |
显示代码纯文本
var
n,m,v,i,j,s,now:longint;
a,b,e:array[0..2000]of longint;
f,g:array[0..1,0..60000]of longint;
begin
assign(input,'criminalb.in'); reset(input);
assign(output,'criminalb.out'); rewrite(output);
readln(n,m,v);
for i:=1 to n do read(e[i]);
for i:=1 to m do
begin
readln(s);
if s>0 then
inc(a[abs(s)])
else inc(b[abs(s)]);
end;
now:=0;
for i:=1 to n do
begin
now:=(now+1) mod 2;
for j:=1 to v do
begin
if (j>=b[i])and(f[(now+1) mod 2,j-b[i]]+e[i]>f[now,j]) then
f[now,j]:=f[(now+1) mod 2,j-b[i]]+e[i];
if (j>=a[i])and(f[(now+1) mod 2,j-a[i]]>f[now,j]) then
f[now,j]:=f[(now+1) mod 2,j-a[i]];
if j>=b[i] then
g[now,j]:=g[(now+1) mod 2,j-b[i]]+e[i];
if (j>=a[i])and(g[(now+1) mod 2,j-a[i]]<g[now,j]) then
g[now,j]:=g[(now+1) mod 2,j-a[i]];
end;
end;
writeln(f[now,v]);
writeln(g[now,v]);
close(input);
close(output);
end.