ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1184. Cable Master

help, TLE#6, here is my code!
Posted by Bobur 11 Apr 2008 23:37
program Project1;

{\$APPTYPE CONSOLE}

uses
SysUtils;

var
i, j, m, n, maxa, x0, xn, x, p : integer;
s : int64;
l : real;
a : array [1..10000] of integer;

begin
maxa := 0;    s := 0;
for i := 1 to n do
begin
a[i] := round(100*l);
s := s + a[i];
if maxa < a[i] then maxa := a[i];
end;
if s div m < 1 then writeLn('0.00')
else
begin
if m = 1 then writeLn(maxa/100:10:2)
else
begin
xn := s div m;
x0 := 0;
repeat
p := 0;
x := (xn+x0) div 3;
for i := 1 to n do
inc(p, a[i] div x);
if p >= m then x0 := x
else xn := x;
until p = m;
for i := xn downto x0 do
begin
p := 0;
for j := 1 to n do
inc(p, a[j] div i);
if p = m then begin writeLn(i/100:0:2);  halt;  end;
end;
end;
end;
end.