### 971 - Towers

Posted:

**Tue Oct 23, 2007 8:50 am**The problem statement has a mistake. I have a lot of TLEs. In first time, I modified problem 10051. This problem runs in O(n*n). But here it is not needed edit rotation of cubes, only height of the tower. Later, I found O(n) algorithm, but still TLE. What is happen? I tried one thing: In my code I changed

while n<>-1 do

begin

...

end;

to

while n>0 do

begin

...

end;

The first is TLE, the second is AC in 0.000. This means, that file don't terminate with -1, but with 0 or another negative number. But problem statement says, "The input terminates by giving the value -1 for N.", what is the mistake...

while n<>-1 do

begin

...

end;

to

while n>0 do

begin

...

end;

The first is TLE, the second is AC in 0.000. This means, that file don't terminate with -1, but with 0 or another negative number. But problem statement says, "The input terminates by giving the value -1 for N.", what is the mistake...