比赛 20101116 评测结果 AAAAAAAAAA
题目名称 打砖块 最终得分 100
用户昵称 Achilles 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-16 08:49:27
显示代码纯文本
program gamea;
var
  i,j,t,n,m,k,q:longint;
  num,qn{i j N},qy{i j Y},dn{No.i j N},dy{No.i j Y}:array[0..201,0..201] of longint;
  yn:array[0..201,0..201] of char;
  temp:char;
begin
  assign(input,'gamea.in');
  assign(output,'gamea.out');
  reset(input);
  rewrite(output);
  readln(n,m,k);
  for i:=1 to n do
  begin
    for j:=1 to m do
      read(num[i,j],temp,yn[i,j]);
    readln;
  end;
  for i:=1 to m do
  begin
    t:=n;
    while (t>0)and(yn[t,i]='Y')do
    begin
      dn[i,0]:=dn[i,0]+num[t,i];
      t:=t-1;
    end;
    for j:=1 to n do
      if t>0 then begin
        dy[i,j]:=dn[i,j-1]+num[t,i];
        dn[i,j]:=dy[i,j];
        t:=t-1;
        while (t>0)and(yn[t,i]='Y') do
        begin
          dn[i,j]:=dn[i,j]+num[t,i];
          t:=t-1;
        end;
      end;
    end;
    for i:=1 to m do
      for j:=0 to k do
        for t:=0 to n do
          if t<=j then begin
            q:=qn[i-1,j-t]+dn[i,t];
            if q>qn[i,j] then
              qn[i,j]:=q;
            if t<j then begin
              q:=qy[i-1,j-t]+dn[i,t];
              if q>qy[i,j] then qy[i,j]:=q;
            end;
            if t>0 then begin
              q:=qn[i-1,j-t]+dy[i,t];
             if q>qy[i,j] then qy[i,j]:=q;
            end;
          end;
  writeln(qy[m,k]);
  close(input);
  close(output);
end.