比赛 |
10.10.18noip模拟 |
评测结果 |
AWWAWWWWWW |
题目名称 |
罪犯问题B |
最终得分 |
20 |
用户昵称 |
donny |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-10-18 21:07:06 |
显示代码纯文本
program criminalb(input,output);
var
n,m,i,j,k,l,o,p,q,max,min:longint;
a:array[0..1000,1..6]of longint;
b:array[0..1000,1..2]of longint;
x:array[1..1000]of longint;
begin
assign(input,'criminalb.in');
reset(input);
assign(output,'criminalb.out');
rewrite(output);
readln(n,m,k);
for i:=1 to n do
read(x[i]);
readln;
for i:=0 to n do
begin
a[i,1]:=0;
a[i,2]:=0;
end;
a[0,3]:=0;
a[0,4]:=0;
a[0,5]:=0;
a[0,6]:=0;
for i:=1 to m do
begin
readln(l);
if l>0 then inc(a[l,1])
else inc(a[abs(l),2]);
end;
for i:=1 to n do
if a[i,1]>=a[i,2] then begin a[i,3]:=a[i,2]; a[i,4]:=x[i]; end
else begin a[i,3]:=a[i,1]; a[i,4]:=0 end;
for i:=1 to n do
if a[i,1]>a[i,2] then begin a[i,5]:=a[i,2]; a[i,6]:=x[i]; end
else begin a[i,5]:=a[i,1]; a[i,6]:=0 end;
if a[1,2]<=k then begin b[1,1]:=a[1,2]; b[1,2]:=x[1]; end
else
begin
if a[1,1]<=k then begin b[1,1]:=a[1,1]; b[1,2]:=0; end
else
begin b[1,1]:=0; b[1,2]:=0; end;
end;
b[0,1]:=0;
b[0,2]:=0;
for i:=2 to n do
if (b[i-1,1]+a[i,2])<=k then
begin
b[i,1]:=b[i-1,1]+a[i,2];
b[i,2]:=b[i-1,2]+x[i];
end
else
begin
l:=a[i,2]+a[i-1,3];
o:=a[i-1,4];
if b[i-1,1]+a[i,1]<=k then
begin
b[i,1]:=b[i-1,1]+a[i,1];
b[i,2]:=b[i-1,2];
end
else
begin
b[i,1]:=0;
b[i,2]:=0;
end;
for j:=i-2 downto 1 do
begin
if b[j,1]+l<=k then
begin
if b[j,2]+x[i]>b[i,2] then
begin
b[i,2]:=b[j,2]+x[i]+o;
b[i,1]:=l+b[j,1];
end;
end
else
l:=l+a[j,3];
o:=o+a[j,4];
end;
end;
max:=b[n,2];
if a[1,1]<=k then begin b[1,1]:=a[1,1]; b[1,2]:=0; end
else
begin
if a[1,2]<=k then begin b[1,1]:=a[1,2]; b[1,1]:=x[1]; end
else
begin b[1,1]:=0; b[1,2]:=0; end;
end;
b[0,1]:=0;
b[0,2]:=0;
for i:=2 to n do
if (b[i-1,1]+a[i,1])<=k then
begin
b[i,1]:=b[i-1,1]+a[i,1];
b[i,2]:=b[i-1,2];
end
else
begin
l:=a[i,1]+a[i-1,5];
o:=a[i-1,6];
if b[i-1,1]+a[i,2]<=k then
begin
b[i,1]:=b[i-1,1]+a[i,2];
b[i,2]:=b[i-1,2]+x[i];
end
else
begin
b[i,1]:=0;
b[i,2]:=maxint;
end;
for j:=i-2 downto 0 do
begin
if b[j,1]+l<=k then
begin
if b[j,2]+o<b[i,2] then
begin
b[i,2]:=b[j,2]+o;
b[i,1]:=l+b[j,1];
end;
end
else
l:=l+a[j,5];
o:=o+a[j,6];
end;
end;
min:=b[n,2];
writeln(max);
writeln(min);
close(input);
close(output);
end.