比赛 20110724 评测结果 AWWTTTWWTW
题目名称 准备工作 最终得分 10
用户昵称 老虎小飞 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-07-24 11:36:06
显示代码纯文本
var
f:array[0..100]of boolean;
p,r,d:array[0..100]of longint;
n,i,j,min,now,ans:longint;

procedure dfs(x:longint);
var
n0,m0,i:longint;
begin
    if x>n then begin
        if min<ans then ans:=min;
    end
    else begin
        n0:=now;m0:=min;
        for i:=1 to n do
            if not f[i] then begin
                if  r[i]>now then begin
                    if ans<r[i]+p[i]-d[i] then exit;
                end
                else begin
                    if ans<now+p[i]-d[i] then exit;
                end;
            end;
        for i:=1 to n do
            if not f[i] then begin
                f[i]:=true;
                if r[i]>now then now:=r[i];
                now:=now+p[i];
                if min<now-d[i] then min:=now-d[i];
                dfs(x+1);
                min:=m0;now:=n0;f[i]:=false;
            end;
    end;
end;

begin
    assign(input,'preparation.in');reset(input);
    assign(output,'preparation.out');rewrite(output);
    read(n); ans:=200000000;min:=-20000000;
    for i:=1 to n do read(p[i]);
    for i:=1 to n do read(r[i]);
    for i:=1 to n do read(d[i]);
    dfs(1);
    writeln(ans);
    close(input);close(output);
end.