|
|
вернуться в форумWhat's wrong? Test 5, time limit exceeded. 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. Послано alp 23 янв 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). |
|
|