比赛 |
20101116 |
评测结果 |
AAAAWWWWWA |
题目名称 |
打砖块 |
最终得分 |
50 |
用户昵称 |
ZhouZn1 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-16 11:15:29 |
显示代码纯文本
program zzn;
type
arr=array[1..100]of integer;
type
rec=record
can:boolean;
num:longint;
end;
var
m,n,i,j,dan,k,ans,sum,up:longint;
a:array[1..200,1..200]of rec;
b:array[1..200,0..200]of longint;
ch:char;
v:array[0..200]of arr;
f:array[0..200]of longint;
procedure init;
begin
assign(input,'gamea.in');
reset(input);
assign(output,'gamea.out');
rewrite(output);
readln(n,m,dan);
sum:=0;
for i:=n downto 1 do
begin
for j:=1 to m do
begin
read(a[i,j].num,ch);
inc(sum,a[i,j].num);
read(ch);
if ch='N' then a[i,j].can:=false else a[i,j].can:=true;
end;
end;
fillchar(v,sizeof(v),0);
end;
procedure closef;
begin
close(input);
close(output);
end;
function min(a,b:longint):longint;
begin
if a<b then exit(a) else exit(b);
end;
procedure change(x:integer;var c:arr);
var
i:integer;
begin
fillchar(c,sizeof(c),0);
i:=m+1;
repeat
dec(i);
c[i]:=x mod 2;
x:=x shr 1;
until x=0;
end;
function can(d,x:integer;c:arr;var ne,ww:integer):boolean;
var
i,s:integer;
begin
s:=0;
ww:=0;
for i:=1 to m do
begin
if c[i]=1 then
begin
inc(s);
inc(ww,a[d,i].num);
end;
end;
ne:=s;
if s>x then exit(false) else exit(true);
end;
function can2(x:integer;c:arr):boolean;
var
i:integer;
begin
for i:=1 to m do
if (c[i]=1)and(v[x-1][i]=0) then exit(false);
exit(true);
end;
procedure dep(x,k:integer;ge:longint);
var
i,ne,ww:integer;
begin
if k=0 then
begin
if ge>ans then ans:=ge;
exit;
end;
if x>n then
begin
if ge>ans then ans:=ge;
exit;
end;
for i:=1 to up do
begin
change(i,v[x]);
if can2(x,v[x]) then
if can(x,k,v[x],ne,ww) then
begin
if ge+ww>ans then ans:=ge+ww;
dep(x+1,k-ne,ge+ww);
end;
end;
end;
procedure main;
begin
if n<=10 then
begin
ans:=0;
for i:=1 to m do v[0][i]:=1;
up:=trunc( exp(m*ln(2)))-1;
dep(1,dan,0);
writeln(ans);
end else
begin
fillchar(b,sizeof(b),0);
for i:=1 to m do
begin
for j:=1 to n do b[i,j]:=b[i,j-1]+a[j,i].num;
end;
fillchar(f,sizeof(f),0);
for i:=1 to m do
begin
for j:=dan downto 1 do
begin
for k:=1 to j do
begin
if f[j]<f[j-k]+b[i,k] then
f[j]:=f[j-k]+b[i,k];
end;
end;
end;
writeln(f[dan]);
end;
end;
begin
init;
main;
closef;
end.