比赛 10.10.18noip模拟 评测结果 WWWAWWWWWW
题目名称 罪犯问题B 最终得分 10
用户昵称 ybh 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-10-18 19:50:15
显示代码纯文本
program criminalb;
var
  f:array[0..50010] of longint;
  c1,c2,w:array[0..1010] of longint;
  n,m,k,i,j,r,sum:longint;

begin
  assign(input,'criminalb.in');
  reset(input);
  assign(output,'criminalb.out');
  rewrite(output);

  readln(n,m,k);
  fillchar(c1,sizeof(c1),0);
  fillchar(c2,sizeof(c2),0);
  fillchar(w,sizeof(w),0);
  sum:=0;
  for i:=1 to n do
  begin
    read(w[i]);
    sum:=sum+w[i];
  end;
  readln;
  for i:=1 to m do
  begin
    readln(r);
    if r>0
      then inc(c1[r])
      else inc(c2[-r]);
  end;

  fillchar(f,sizeof(f),0);
  for i:=1 to n do
    for j:=k downto c2[i] do
      if f[j-c2[i]]+w[i]>f[j]
        then f[j]:=f[j-c2[i]]+w[i];
  writeln(f[k]);

  fillchar(f,sizeof(f),0);
  for i:=1 to n do
    for j:=k downto c1[i] do
      if f[j-c1[i]]+w[i]>f[j]
        then f[j]:=f[j-c1[i]]+w[i];
  writeln(sum-f[k]);

  close(input);
  close(output)
end.