fishing2.pas
来自「PASCAL光盘资料PASCAL光盘资料PASCAL光盘资料」· PAS 代码 · 共 72 行
PAS
72 行
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 + =
减小字号Ctrl + -
显示快捷键?