比赛 10101115 评测结果 AWAWEEEEEE
题目名称 技能树 最终得分 20
用户昵称 reamb 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-15 09:31:21
显示代码纯文本
  1. program jinengshu;
  2. var
  3. f:array[0..10,0..10,0..11,0..100] of longint;
  4. sum,a:array[1..10,0..10]of longint;
  5. i,j,k,l,p,q,max,s,d,n,m:longint;
  6. begin
  7. assign (input,'skill.in');
  8. reset (input);
  9. assign (output,'skill.out');
  10. rewrite (output);
  11. readln (n,m);
  12. for i:=1 to n do
  13. begin
  14. for j:=1 to n-i+1 do
  15. begin
  16. read (a[i,j]);
  17. sum[i,j]:=sum[i,j-1]+a[i,j]
  18. end;
  19. readln
  20. end;
  21. for i:=1 to n do
  22. for j:=1 to n-i+1 do
  23. for k:=j to n-i+1 do
  24. for l:=1 to m do
  25. begin
  26. d:=k-j+1;
  27. if l>=d then
  28. begin
  29. max:=0;
  30. s:=sum[i,k]-sum[i,j-1];
  31. for p:=j downto 1 do
  32. for q:=k+1 to n-i+2 do
  33. if f[i-1,p,q,l-d]+s>max then
  34. max:=f[i-1,p,q,l-d]+s;
  35. f[i,j,k,l]:=max
  36. end
  37. end;
  38. max:=0;
  39. for i:=1 to n do
  40. for j:=1 to n-i+1 do
  41. for k:=i to n-i+1 do
  42. if f[i,j,k,m]>max then
  43. max:=f[i,j,k,m];
  44. writeln (max);
  45. close (input);
  46. close (output)
  47. end.