比赛 20110724 评测结果 TTTTWWTTWT
题目名称 准备工作 最终得分 0
用户昵称 wo shi 刘畅 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2011-07-24 12:44:25
显示代码纯文本
var
  n,i,time,now,ans,t,x,y:longint;
  p,a,s,r,d:array[0..100000]of longint;

function max(x,y:longint):longint;
begin
  if x>y then exit(x);
  exit(y);
end;

begin
  assign(input,'preparation.in'); reset(input);
  assign(output,'preparation.out'); rewrite(output);
  readln(n);
  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]);
  randomize;
  ans:=maxlongint;
  for i:=1 to n do a[i]:=i;
  ans:=maxlongint;
  for time:=1 to 20000000 div n do
  begin
    for i:=1 to n do s[i]:=0;
    s[1]:=r[a[1]];
    now:=r[a[1]]+p[a[1]];
    for i:=2 to n do
    begin
      s[i]:=max(now,r[a[i]]);
      now:=s[i]+p[a[i]];
    end;
    now:=0;
    for i:=1 to n do now:=max(now,s[i]+p[a[i]]-d[a[i]]);
    if now<ans then ans:=now;
    x:=random(n)+1;
    y:=random(n)+1;
    t:=a[x];
    a[x]:=a[y];
    a[y]:=t;
  end;
  writeln(ans);
  close(input);
  close(output);
end.