比赛 |
10.10.18noip模拟 |
评测结果 |
WWWWWWWWTT |
题目名称 |
罪犯问题B |
最终得分 |
0 |
用户昵称 |
苏轼 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-10-18 20:34:04 |
显示代码纯文本
program criminalb(input,output);
const
MMMAX=10000000;
var
i,j,n,m,k,a,b:longint;
xe:array[1..1000,0..3]of word;
dym:array[0..30000,0..1000]of longint;
function max(a,b:longint):longint;
begin
if a>b then
exit(a)
else
exit(b);
end;
function min(a,b:longint):longint;
begin
if a>b then
exit(b)
else
exit(a);
end;
begin
assign(input,'criminalb.in');
reset(input);
assign(output,'criminalb.out');
rewrite(output);
readln(n,m,k);
for i:=1 to n do
read(xe[i,0]);
for i:=1 to m do
begin
read(j);
if (j>0)and(xe[j,0]=0) then
dec(k)
else if xe[abs(j),0]<>0 then
begin
if j>0 then
inc(xe[j,1])
else
inc(xe[-j,2]);
end;
end;
for i:=1 to k do
for j:=1 to n do
begin
a:=0;
b:=0;
if xe[j,1]<=i then
a:=dym[i-xe[j,1],j-1];
if xe[j,2]<=i then
b:=dym[i-xe[j,2],j-1]+xe[j,0];
if a>=MMMAX then
a:=b;
dym[i,j]:=max(a,b);
if (xe[j,1]>i)and(xe[j,2]>i) then
dym[i,j]:=MMMAX;
end;
writeln(dym[k,n]);
for i:=1 to k do
for j:=1 to n do
begin
a:=MMMAX;
b:=MMMAX;
if xe[j,1]<=i then
a:=dym[i-xe[j,1],j-1];
if xe[j,2]<=i then
b:=dym[i-xe[j,2],j-1]+xe[j,0];
if a=0 then
a:=b;
dym[i,j]:=min(a,b);
if (xe[j,1]>i)and(xe[j,2]>i) then
dym[i,j]:=0;
end;
writeln(dym[k,n]);
close(input);
close(output);
end.