记录编号 22009 评测结果 AAAAWWWWWA
题目名称 打砖块 最终得分 50
用户昵称 Gravatar苏轼 是否通过 未通过
代码语言 Pascal 运行时间 0.512 s
提交时间 2010-11-16 15:37:15 内存使用 2.58 MiB
显示代码纯文本
program gamea(input,output);

type
  re=record
    f:longint;
    c:byte;
  end;

var
  n,m,k,i,j,ii:longint;
  ch:char;
  map:array[-201..201,-200..201]of re;
  sum:array[-201..201,-200..201]of longint;
  f:array[-201..201,-200..201]of longint;

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

  readln(n,m,k);

  for i:=1 to n do
    for j:=1 to m do
    begin
      read(map[i,j].f,ch);
      read(ch);

      if ch='N' then
        map[i,j].c:=0
      else
        map[i,j].c:=1;
    end;

  for i:=1 to m do
    for j:=k downto 1 do
      if map[j,i].c=1 then
      begin
        map[j-1,i].f:=map[j-1,i].f+map[j,i].f;
        for ii:=j downto 1 do
          map[ii,i]:=map[ii-1,i];
      end;

  for i:=1 to m do
    for j:=1 to k do
      sum[i,j]:=sum[i,j-1]+map[n-j+1,i].f;

  for i:=1 to m do
    for j:=0 to k do
      for ii:=0 to j do
        if f[i-1,j-ii]+sum[i,ii]>f[i,j] then
          f[i,j]:=f[i-1,j-ii]+sum[i,ii];

  writeln(f[m,k]);

  close(input);
  close(output);
end.