记录编号 19992 评测结果 AAAAAAAAAA
题目名称 罪犯问题B 最终得分 100
用户昵称 Gravatarbelong.zmx 是否通过 通过
代码语言 Pascal 运行时间 0.152 s
提交时间 2010-10-19 18:32:15 内存使用 0.31 MiB
显示代码纯文本
program criminalb(input,output);
var
 n,m,k:longint;
 evil:array[1..1000]of integer;
 a:array[1..1000,1..2]of integer;
 f:array[0..50000]of longint;
 i,j,max,x,t:longint;

function min(x,y:longint):longint;
begin
 if x>y then min:=y else min:=x;
end;

begin
 assign(input,'criminalb.in');
 reset(input);
 readln(n,m,k);
 for i:=1 to n do
 begin
  read(evil[i]);
  max:=max+evil[i];
 end;
 readln;
 for i:=1 to m do
 begin
  readln(x);
  if x>0 then inc(a[x,1]);
  if x<0 then inc(a[-x,2]);
 end;
 close(input);

 for i:=1 to n do
 begin
  x:=min(a[i,1],a[i,2]);
  a[i,1]:=a[i,1]-x;
  a[i,2]:=a[i,2]-x;
  k:=k-x;
 end;

 assign(output,'criminalb.out');
 rewrite(output);

 for i:=1 to n do
  for j:=k downto a[i,2] do
  begin
   if f[j-a[i,2]]+evil[i]>f[j] then f[j]:=f[j-a[i,2]]+evil[i];
  end;
 writeln(f[k]);

 for i:=0 to k do f[i]:=0;

 for i:=1 to n do
  for j:=k downto a[i,1] do
  begin
   if f[j-a[i,1]]+evil[i]>f[j] then f[j]:=f[j-a[i,1]]+evil[i];
  end;
 writeln(max-f[k]);

 close(output);
end.