比赛 20101116 评测结果 AWWWEEEEEA
题目名称 打砖块 最终得分 20
用户昵称 maxiem 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-16 11:26:00
显示代码纯文本
  1. program gamea;
  2. var
  3. code,i,j,k,a,t,n,m,tmp:longint;
  4. table,rown,rowy,sumy,sumn:array [0..201,0..201] of longint;
  5. extra:array [1..201,1..201] of boolean;
  6. s:string;
  7. begin
  8. fillchar (rown,sizeof(rown),0);
  9. fillchar (rowy,sizeof(rowy),0);
  10. fillchar (sumn,sizeof(sumn),0);
  11. fillchar (sumy,sizeof(sumy),0);
  12. fillchar (table,sizeof(table),0);
  13. assign (input,'gamea.in');
  14. reset (input);
  15. readln (n,m,k);
  16. for i:=1 to n do begin
  17. readln (s);s:=s+' ';
  18. j:=1;
  19. while s<>'' do begin
  20. val (copy(s,1,pos(' ',s)-1),table[i,j],code);
  21. delete (s,1,pos(' ',s));
  22. if s[1]='Y' then extra[i,j]:=true else extra[i,j]:=false;
  23. delete (s,1,pos(' ',s));
  24. inc(j);
  25. end;
  26. end;
  27. close (input);
  28. assign (output,'gamea.out');
  29. rewrite (output);
  30. for i:=1 to m do begin
  31. t:=n;
  32. while (t>0) and (extra[i,j]) do begin
  33. rown[i,0]:=rown[i,0]+table[t,i];
  34. dec(t);
  35. end;
  36. for j:=1 to n do begin
  37. rowy[i,j]:=rown[i,j-1]+table[t,i];
  38. rown[i,j]:=rowy[i,j];
  39. dec(t);
  40. while (t>0) and (extra[t,i]) do begin
  41. rown[i,j]:=rown[i,j]+table[t,i];
  42. dec(t);
  43. end;
  44. if t<=0 then break;
  45. end;
  46. end;
  47. for j:=1 to m do begin
  48. for i:=0 to k do begin
  49. for a:=0 to n do begin
  50. if a<=i then begin
  51. tmp:=sumn[j-1,i-a]+rown[j,a];
  52. if tmp>sumn[j,i] then sumn[j,i]:=tmp;
  53. if k<i then begin
  54. tmp:=sumy[j-1,i-a]+rown[j,a];
  55. if tmp>sumy[j,i] then sumy[j,i]:=tmp;
  56. end;
  57. if k>0 then begin
  58. tmp:=sumn[j-1,i-a]+rowy[j,a];
  59. if tmp>sumy[j,i] then sumy[j,i]:=tmp;
  60. end;
  61. end;
  62. end;
  63. end;
  64. end;
  65. writeln (sumy[m][k]);
  66. close (output);
  67. end.