Why my program keeps getting Time Limit Exceeded? What are some of the reasons of getting TLE? asked 20 Mar '13, 16:22

@dragonemperor @betlista @admin how to input a string whose number of characters we do not know using scanf in c++ ?? answered 30 Mar '16, 19:54
Hey @rajvir007 here is the solution to your question which I posted in discuss as a new question https://discuss.codechef.com/questions/80575/inputstringinc More over I have upvoted your question so that you can now ask question on your own and upvote and participate in codechef discuss and community rather that posting questions in answer column of editorials.
(31 Mar '16, 11:39)

It means the program you are using is doing more computations than expected. Usually, loops that goes upto 10^610^7 are acceptable with 12s time limit. It usually depends on the problem. answered 26 Oct '15, 23:43

Implementation of wrong or way of use(algorithm) data structure . answered 27 Oct '15, 13:17

can anybody tell me what is the problem in my code i am getting TLE erroe when submitted. http://code.geeksforgeeks.org/eNfy3Q answered 29 Oct '15, 18:07

1 . High Complexity. 2. Sometimes due to IO functions. Try to use Fast IO or optimize your code as much as possible. answered 06 Apr '16, 11:22

include<stdio.h>long int prod(long int ar[],long int x){ long int p,s=0; if(x==1)return ar[0]; else if(x==2)return ar[1]*ar[0]+ar[1]+ar[0]; else { for(p=2;p<x;p++)s=ar[p]*(1+prod(ar,x1))+prod(ar,x1);} return="" s;="" }="" int="" magic(long="" int="" n){="" long="" int="" c="1,nn,i=0,p,q=n,j,k,s=0,ar[10000];" nn="0;p=n;" while(p="">0){p=p/10;nn++;} long int a[nn];while(n>0){a[i]=n%10;i++;n=n/10;} s=prod(a,nn); if(s%2==0)return 1; else return 0; } int main(){ long int n,c,i,t,j,k; scanf("%ld",&t); for(j=0;j<t;j++){k=1; scanf("%ld",&i);n=0; while(k<=i){ if(magic(n)==1)k++;n++; }
} } //This is my code for chef hiring problem(codeCHEARMY).why am i getting TLE in codechef? but it is running successfully in my computer. answered 10 Jun '16, 14:22

how to avoid loop that goes upto 10^6 or 10^12? what is the alternative for it? answered 11 Jun '16, 15:49

include<stdio.h>int main() { long int a[10000001],n,t,i,j; scanf("%d",&n); for(i=0;i<n;i++) {="" scanf("%d",&a[i]);="" }="" for(i="0;i<n;i++)" {="" for(j="0;j<(n1);j++)" {="" if(a[j]="">a[j+1]) { t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } } for(i=0;i<n;i++) { printf("%d",a[i]); } return 0; }
answered 02 Jul '16, 19:37

guys, I have got 1 karma. please increase my karma(by liking) to 3,so that i could ask my doubts in the forum. Thanks in advance for spending your time. answered 03 Jul '16, 14:19

Hey I am new to CodeChef and I am not comfortable with this time limit for execution. My all algorithms are logically correct and my program is working perfectly fine on my system but on codechef it is showing TLE error. Program name is Chef And Keyboard(CHEFKEY): https://www.codechef.com/problems/CHEFKEY My solution: https://github.com/ishaan123/CodeChef/blob/master/codechef2.cpp answered 06 Nov '16, 15:28

include <stdio.h>int main() { int i,t,c=d=e=f=0,g,h,N,X[N],Y[N]; scanf("%d",&t);
why do i get a timi limit error?? answered 10 Mar '17, 13:36

include<stdio.h>int main() { int t,m[10],n[10],i,j,primes[10^7+1]; for(i=0;i<=10^7;i++) primes[i]=1; primes[0]=0; primes[1]=0; for(i=2;ii<=10^7;i++) { if(primes[i]==1) { for(j=2;ij<=10^7;j++) primes[i*j]=0; } } scanf("%d",&t); for(i=1;i<=t;i++) scanf("%d%d",&m[i],&n[i]); for(i=1;i<=t;i++) { for(j=m[i];j<=n[i];j++) { if(primes[j]==1) printf("%d\n",j); } printf("\n"); } return 0; } answered 11 Aug '17, 12:03

y i m getting TLE in my code can anyone help
Code answered 20 Jan, 22:55
