## 440 TLE?

Moderator: Board moderators

### 440 TLE?

[cpp]

why i am getting TLE?[/cpp]
sami
New poster

Posts: 2
Joined: Tue Jan 28, 2003 7:25 am
Location: pakistan

I think, that's too litle informations to say why

Dominik
Dominik Michniewski
Guru

Posts: 828
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland

is there any speciality in its implementation or brute force is the solution..
sami
New poster

Posts: 2
Joined: Tue Jan 28, 2003 7:25 am
Location: pakistan

what's wrong in this, i getting WA

Code: Select all
`var a:array[1..100] of shortint;b:array[1..100] of byte;i,j,u,z,k,n,r,l:longint;beginb[1]:=1;repeatinc(i);readln(a[i]);until a[i]=0;n:=i-1;for i:=1 to n do beginr:=a[i];j:=1;repeatinc(j);l:=1;k:=1;for z:=2 to r dob[z]:=0;        repeat        u:=0;                repeat                inc(l);                if l=r+1 then begin                l:=1;                repeat                inc(l);                until b[l]=0;                end;                if b[l]=0 then inc(u);                until u=j;        b[l]:=1;                inc(k);        until k=r;until l=2;a[i]:=j;end;for i:=1 to n dowriteln(a[i]);readln;end.`
gates1
New poster

Posts: 7
Joined: Tue May 01, 2007 2:11 pm

### Re: 440 TLE?

I have seen the ranking is 0.000 for this program. But my one is very slow !!!
I made a normal simulation to calculate the value. Is there any trick to find the value.
I hate such slow codes.
try_try_try_try_&&&_try@try.com
This may be the address of success.
Obaida
A great helper

Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 440 TLE?

This is how you can get this code done in very short time. When I submitted this code for the first time, I got AC , but the runtime was 0.904 seconds. Then I realized that 3<=n<=150, and an idea suddenly struck my head. I removed scanf("%d",&n);
and the for loop was replaced with for(n = 3; n < 150; n++) from my original code. After I calculated the result, I simply printed printf("if(n == %d) printf("%d\n");", n, result); and copied the printed lines from the terminal and pasted them. I got AC in 0.08 seconds . It is impossible to get 0.000 runtime nowadays, it sucks lol.
Note you need to add an escape character before " and \n in order to print them. And try to find an optimized solution before you do this. But we all know that everything is fair in war and programming
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

plamplam
Experienced poster

Posts: 151
Joined: Fri May 06, 2011 11:37 am