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

Please help me to find a mistake
Posted by Simeon Iksanov 8 Oct 2004 19:31
my program is :

var x, y:real;
    x0, y0 : integer;
    a, b : real;
    count,i : integer;
    Max, Temp : real;

Function f(x,y : real) : real;
begin
    f:=a*x+b*y-x*x-y*y;
end;
BEGIN
  x0:=0;
  y0:=0;
  Max := -99999999;
  Readln(a,b);
  readln(count);
  x := a/2;
  y := b/2;
  x:=trunc(x);
  y:=trunc(y);
  x0:=round(x);
  y0:=round(y);
if (x+y)<=count then
begin
    max:=f(x,y);
    if ( (x+1+y)<=count) and (max<f(x,y+1)) then
    begin
        y0:=round(y+1);
        max:=f(x,y0);
    end;
    if ((x+1+y)<=count) and (f(x+1,y)>max) then
    begin
        x0:=round(x+1);
        max:=f(x0,y);
    end;
end
else
begin
    for i:=0 to count do
    begin
        x:=i;
        y:= count-x;
        if f(x,y)>max then
        begin
            x0:=round(x);
            y0:=round(y);
            max:=f(x0,y0);
        end;

    end;
end;
max := f(x0,y0);
if (x0<0) and (y0<0) then
begin
  x0 := 0;
  y0 := 0;
  max := 0;
end;
    Writeln(max:1:2);
    Writeln(x0,' ',y0);
END.