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 1079. Maximum

What's wrong? Test 5, time limit exceeded.
Posted by Evgeny G 21 Jan 2012 12:01
var a:array[0..100000] of integer;
i,n,imax:integer;
begin
 n:=1;
 imax:=0;
 while n>0 do
  begin
    readln(n);
    if n=0 then exit;
      a[0]:=0;
      a[1]:=1;
    for i:=1 to n do
     begin
      a[2*i]:=a[i];
      a[2*i+1]:=a[i]+a[i+1];
     end;
  for i:=0 to n do
   if a[i]>=a[imax] then imax:=i;
 writeln(a[imax]);
 end;
end.

Why TLEX?
Re: What's wrong? Test 5, time limit exceeded.
Posted by alp 23 Jan 2012 00:46
Try test
99 999
99 999
99 999
99 999
99 999
99 999
99 999
99 999
99 999
99 999
0
Calculation max once.
Now you calculate 2 time (main cicle and for search max).