What does " Time Limit Exceeded" status mean after submission

TLE means your code takes too long to run.

Your code:
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		for(int i=0; i<T; i++){
			int N = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
			int C = sc.nextInt();
			int type1 = 0, type2 = 0;
			while(B!=0 || B>0){
				if(A!=0 && B>0){
					A--;
					B--;
					type1++;
				}
				if(C!=0 && B>0){
					B--;
					C--;
					type2++;
				}
				if(A==0 && C==0)
					B--;
			}
			int res = type1+type2;
			if(res>=N)
				System.out.println("Yes");
			else
				System.out.println("No");
		}
	}
}

Your Input:

1
1 1 1 1

Time to run: 0.169692 secs

Your Input:

1
1 1 1 0

Time to run: 4.56118 secs

The error lies with your if-statements. It is possible to reduce B by 2 in the same loop iteration even when B is only 1. This causes B to become negative and since your while loop does not stop when B is negative, the loop just keeps running.

You may want to check out how to use else if, else, and continue

1 Like

It means your code is not optimized…optimized in the sense of time complexity(generally)…try not using nested loops…or infinite loop(might be check your terminating condition very carefully) also always check the constraints at least a small glance will help…bigger input == more optimized code needed…All the best…