55 lines
1.4 KiB
Plaintext

program fishing1; //̰ÐÄ·¨
const maxF = 1000;
maxN = 100;
type nodeP = record
fish,delta,time:longint;
end;
var Hash:array[0..maxF] of longint;
Pound:array[1..maxN] of nodeP;
ans,n,t,i:longint;
procedure Doit;
var i,j,remain,tmp:longint;
begin
for i:=1 to n do
with pound[i] do
begin
dec(t,time);
for j:=0 to fish div delta do inc(Hash[fish-j*delta]);
tmp:=0;
remain:=t;
j:=maxF;
while remain>0 do
begin
while (Hash[j]=0) and (j>0) do dec(j);
if j=0 then break;
if Hash[j]<=remain then
begin
dec(remain,Hash[j]);
inc(tmp,Hash[j]*j)
end
else begin
inc(tmp,remain*j);
remain:=0
end;
dec(j)
end;
if tmp>ans then ans:=tmp
end
end;
begin //main
assign(input,'fishing.in'); reset(input);
assign(output,'fishing.out'); rewrite(output);
readln(n);
for i:=1 to n do read(pound[i].fish); readln;
for i:=1 to n do read(pound[i].delta); readln;
for i:=1 to n-1 do read(pound[i+1].time); readln;
readln(t);
ans:=-maxlongint;
Doit; //̰ÐĹý³Ì
writeln(ans);
close(input); close(output)
end.