比赛 20101116 评测结果 AWWWEEEEEA
题目名称 打砖块 最终得分 20
用户昵称 maxiem 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-16 11:26:00
显示代码纯文本
program gamea;
var
  code,i,j,k,a,t,n,m,tmp:longint;
  table,rown,rowy,sumy,sumn:array [0..201,0..201] of longint;
  extra:array [1..201,1..201] of boolean;
  s:string;
begin
  fillchar (rown,sizeof(rown),0);
  fillchar (rowy,sizeof(rowy),0);
  fillchar (sumn,sizeof(sumn),0);
  fillchar (sumy,sizeof(sumy),0);
  fillchar (table,sizeof(table),0);
  assign (input,'gamea.in');
  reset (input);
  readln (n,m,k);
  for i:=1 to n do begin
    readln (s);s:=s+' ';
	j:=1;
	while s<>'' do begin
	  val (copy(s,1,pos(' ',s)-1),table[i,j],code);
	  delete (s,1,pos(' ',s));
	  if s[1]='Y' then extra[i,j]:=true else extra[i,j]:=false;
	  delete (s,1,pos(' ',s));
	  inc(j);
	end;
  end;
  close (input);
  assign (output,'gamea.out');
  rewrite (output);
  for i:=1 to m do begin
    t:=n;
	while (t>0) and (extra[i,j]) do begin
	  rown[i,0]:=rown[i,0]+table[t,i];
	  dec(t);
	end;
	for j:=1 to n do begin
	  rowy[i,j]:=rown[i,j-1]+table[t,i];
	  rown[i,j]:=rowy[i,j];
	  dec(t);
          while (t>0) and (extra[t,i]) do begin
            rown[i,j]:=rown[i,j]+table[t,i];
            dec(t);
          end;
          if t<=0 then break;
	end;
  end;
  for j:=1 to m do begin
    for i:=0 to k do begin
	  for a:=0 to n do begin
	    if a<=i then begin
		  tmp:=sumn[j-1,i-a]+rown[j,a];
		  if tmp>sumn[j,i] then sumn[j,i]:=tmp;
		  if k<i then begin
		    tmp:=sumy[j-1,i-a]+rown[j,a];
			if tmp>sumy[j,i] then sumy[j,i]:=tmp;
		  end;
		  if k>0 then begin
		    tmp:=sumn[j-1,i-a]+rowy[j,a];
			if tmp>sumy[j,i] then sumy[j,i]:=tmp;
		  end;
		end;
	  end;
	end;
  end;
  writeln (sumy[m][k]);
  close (output);
end.