比赛 20121108 评测结果 EEEEEEEEEEEEEEEEEEEE
题目名称 还是“金明的预算方案” 最终得分 0
用户昵称 digital-T 运行时间 0.002 s
代码语言 Pascal 内存使用 0.93 MiB
提交时间 2012-11-08 11:57:29
显示代码纯文本
var
n,l,w,limit,i,j,www,a,b,s:longint;
ab:array[0..10]of integer;
c,d,k,num:array[1..60]of longint;
t:array[0..200000]of longint;
fc,fd:array[1..60,1..10]of longint;
ww:word;
begin
assign(input,'budget.in');reset(input);
assign(output,'budget.out');rewrite(output);
fillchar(t,sizeof(t),0);
fillchar(fc,sizeof(fc),0);
fillchar(fd,sizeof(fd),0);
fillchar(num,sizeof(num),0);
read(limit,n,s);
for l:=1 to n do
begin
read(c[l],d[l],k[l]);
 if k[l]>0 then
 begin
  inc(num[k[l]]);
  fc[k[l],num[k[l]]]:=c[l];
  fd[k[l],num[k[l]]]:=d[l];
 end;
end;
//for i:=1 to n do writeln(i,' ',num[i],' 1>>',fc[i,1],' ',fd[i,1],' 2>>',fc[i,2],' ',fd[i,2]);
ab[0]:=1;
for l:=1 to s do ab[l]:=ab[l-1]*2;
//________________________________
for l:=1 to n do
 if k[l]=0 then
 for w:=limit-c[l] downto 0 do
{1 }begin
   if(w=0)or(t[w]>0)then
{  2 }begin
     if t[w+c[l]]<t[w]+c[l]*d[l] then t[w+c[l]]:=t[w]+c[l]*d[l];

     if num[l]>0 then
{    3 }begin
       for ww:=1 to ab[num[l]]-1 do
{      4 }begin
         a:=t[w]+c[l]*d[l];
         b:=w+c[l];

         for www:=1 to num[l] do
          if ww shl(10-www)shr 9=1 then
{         5 }begin
            a:=a+fc[l,www]*fd[l,www];
            b:=b+fc[l,www];
            if a>200000 then begin a:=0;break;end;
{         5 }end;

         if a>0 then
          if a>t[b] then t[b]:=a;
{      4 }end;
{    3 }end;

{  2 }end;
{1 }end;
//______________________________________________
l:=0;
for w:=limit downto 1 do if t[w]>l then l:=t[w];
write(l);
close(input);
close(output);
end.