📄 fishing2.pas
字号:
program fishing(input,output);{贪心}
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:longint;
procedure setIO;
begin
assign(input,'fishing.in');
reset(input);
assign(output,'fishing.out');
rewrite(output);
end;
procedure Init;
var i:longint;
begin
read(n);
for i:=1 to n do read(pound[i].fish);
for i:=1 to n do read(pound[i].delta);
for i:=1 to n-1 do read(pound[i+1].time);
read(t);
ans:=-maxlongint;
end;
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;
procedure Print;
begin
writeln(ans);
close(output);
end;
begin
setIO;
Init;
Doit;
Print;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -