比赛 20100913 评测结果 WAWAWWWAWA
题目名称 餐巾 最终得分 40
用户昵称 Achilles 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-09-13 21:36:41
显示代码纯文本
program napkin;
var
  d,a,c:array[1..200] of longint;
  i,j,q,w,e,r,t,n,o,l,k:longint;
  b,bi:array[1..200,1..6] of longint;
  tot,max,tt,ll:longint;
  p:boolean;
begin
  assign(input,'napkin.in');
  reset(input);
  assign(output,'napkin.out');
  rewrite(output);
  readln(n);
  for i:=1 to n do read(d[i]);
  for i:=1 to n do max:=max+d[i];
  readln(q,w,e,r,t);
  tt:=maxlongint;
  for l:=d[1] to max do begin
    p:=true;
    fillchar(b,sizeof(b),0);
    a:=d;
    c:=a;
    ll:=l;
    k:=1;
    while d[k]<ll do
    begin
      b[k,2]:=a[k];
      ll:=ll-a[k];
      inc(k);
    end;
    b[k,2]:=ll;
    a[k]:=a[k]-ll;
    tot:=l*q;
    for i:=k to n do
    begin
      for j:=i-r downto 1 do if c[j]>0 then
        if c[j]>=a[i] then begin
          c[j]:=c[j]-a[i];
          b[i,6]:=b[i,6]+a[i];
          b[j,4]:=b[j,4]+a[i];
          tot:=tot+a[i]*t;
          a[i]:=0;
          break;
        end
        else begin
          a[i]:=a[i]-c[j];
          b[i,6]:=b[i,6]+c[j];
          b[j,4]:=b[j,4]+c[j];
          tot:=tot+c[j]*t;
          c[j]:=0;
        end;
        if a[i]>0 then if i-w>0 then begin
          if i-r+1>0 then o:=i-r+1 else o:=1;
            for j:=i-w downto o do if c[j]>0 then
              if c[j]>=a[i] then begin
                c[j]:=c[j]-a[i];
                b[i,5]:=b[i,5]+a[i];
                b[j,3]:=b[j,3]+a[i];
                tot:=tot+a[i]*e;
                a[i]:=0;
                break;
              end
              else begin
                a[i]:=a[i]-c[j];
                b[i,5]:=b[i,5]+c[j];
                b[j,3]:=b[j,3]+c[j];
                tot:=tot+c[j]*e;
                c[j]:=0;
              end;
        end;
        if a[i]>0 then begin
          p:=false;
          break;
        end;
    end;
    if p and (tot<tt) then begin
      tt:=tot;
      bi:=b;
    end;
  end;
  writeln(tt);
  for i:=1 to n do
    bi[i,1]:=d[i];
  for i:=1 to n do
  begin
    for j:=1 to 6 do
      write(bi[i,j],' ');
    writeln;
  end;
  close(input);
  close(output);
end.