ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1200. Horns and Hoofs

I have tried many times.But I always got WA.Who can help me???
Posted by wangchun 13 May 2004 21:17
const max=10000;
var a,b,out,temp:real;
    k,t,al,bl,m,n:integer;
    s1,s2:array[0..max]of real;
begin
     readln(a,b);
     readln(k);
     al:=-1;
     bl:=-1;
     for t:=1 to k do
         begin
              s1[t]:=a*t-t*t;
              s2[t]:=b*t-t*t;
              if (s1[t]<=s1[t-1])and(al=-1) then
                 al:=t-1;
              if (s2[t]<=s2[t-1])and(bl=-1) then
                 bl:=t-1;
              if (al<>-1)and(bl<>-1) then
                 break;
         end;
     if al+bl<=k then
        begin
             out:=s1[al]+s2[bl];
             writeln(out:0:2);
             writeln(al,' ',bl);
             halt;
        end;
     m:=0;
     n:=0;
     out:=0;
     for t:=k-bl to al do
         begin
              temp:=s1[t]+s2[k-t];
              if temp>out then
                 begin
                      out:=temp;
                      m:=t;
                      n:=k-t;
                 end;
         end;
     writeln(out:0:2);
     writeln(m,' ',n);
end.
You got WA on test 5. Here is it.
Posted by TECTOBOP 14 May 2004 16:20
Input:
5434.87 -4567
300
Correct output:
1540461.00
300 0
Your output:
0.00
-1 0
It is wrong.