Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

【新】WA了无数次

Posted by Shizhouxing at 2011-06-06 17:44:58 on Problem 1042
var
    time,t,f,d,ans:array[1..100]of longint;
    s,max,best,i,j,k,n,tmp,h,l:longint;
procedure main();
    var tf:array[1..100]of longint;
    begin
       best:=0;
       for i:=1 to n do
         begin
           tmp:=h;
           tf:=f;
           for j:=1 to i-1 do
              tmp:=tmp-t[j];
           fillchar(time,sizeof(time),0);
           s:=0;
           for j:=1 to tmp do
             begin
               max:=1;
               for k:=1 to i do
                if (tf[k]>tf[max]) then max:=k;
               if tf[max]<=0 then begin
                 time[1]:=time[1]+(tmp-j+1)*5;
                 break;
               end;
               s:=s+tf[max];
               tf[max]:=tf[max]-d[max];
               time[max]:=time[max]+5;
             end;
           if s>best then begin
              best:=s;
              ans:=time;
           end
           else if s=best then begin
              for l:=1 to n do begin
                if (time[l]>ans[l])and(s=best) then begin
                  best:=s;
                  ans:=time;
                  break;
                end;
                if time[l]<ans[l] then break;
         end;
         end;
         end;
         for i:=1 to n-1 do write(ans[i],',');
         writeln(ans[n]);
         if best=0 then writeln(best)
         else writeln('Number of fish expected: ',best);
end;
begin
    readln(n);
    while n<>0 do begin
        readln(h);
        h:=h*60 div 5;
        for i:=1 to n do read(f[i]);
        for i:=1 to n do read(d[i]);
        for i:=1 to n-1 do read(t[i]);
        main();
        readln(n);
    end;
end.
请神牛们帮忙看一下,本人深表感谢。(参考刘汝佳)

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator