| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
哪里出问题了?program gone_fishing;
var
f,d,e,t,time,ans:array[0..30] of longint;
n,h,ansnow:longint;
firstwrite:boolean;
procedure init;
var
i:longint;
begin
readln(h);
h:=h*60;
for i:=1 to n do
read(f[i]);
readln;
for i:=1 to n do
read(d[i]);
readln;
for i:=1 to n-1 do
read(t[i]);
t[0]:=0;
readln;
end;
procedure main;
var
k,i,j,p,q,tmp,sum:longint;
begin
ansnow:=-1;
for k:=0 to n-1 do
begin
dec(h,5*t[k]);
e:=f;
tmp:=0;
fillchar(time,sizeof(time),0);
for i:=1 to h div 5 do
begin
q:=-1;
p:=0;
for j:=1 to k+1 do
if e[j]>q then
begin
q:=e[j];
p:=j;
end;
if p = 0 then
break;
inc(tmp,e[p]);
inc(time[p]);
dec(e[p],d[p]);
end;
if tmp > ansnow then
begin
ansnow:=tmp;
sum:=0;
for i:=1 to n do
begin
ans[i]:=time[i];
inc(sum,time[i]);
end;
inc(ans[1],h div 5-sum)
end;
end;
end;
procedure outit;
var
i:longint;
begin
if firstwrite then
writeln
else
firstwrite:=true;
for i:=1 to n-1 do
write(ans[i]*5,', ');
writeln(ans[n]*5);
writeln('Number of fish expected: ',ansnow);
end;
begin
readln(n);
firstwrite:=false;
while n<>0 do
begin
init;
main;
outit;
readln(n);
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator