Why getting TLE

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
try{
Scanner sc =new Scanner(System.in);
int T = sc.nextInt();
while(T!=0){
int N = sc.nextInt();
int K = sc.nextInt();
int max;
int pair;

	      //  if(N/2 > K){
	      //       max = (N/K) + 1;
	      //       pair = N/max - 1;
	      //      System.out.println(max + " " + pair);
	      //  }
	      //  if(N/2 < K){
	      //      int M = K - 1;
	      //      max = N/M;
	      //      pair = N/max - 1;
	      //      System.out.println(max + " " + pair);
	      //  }
	        if(N%K != 0){
	            max = N/K + 1;
	            pair = N - K*(N/K);
	            System.out.println(max + " " + pair );
	        }
	        if(N/2 == K){
	            max = N/K;
	            pair = K;
	            System.out.println(max + " " + pair);
	        }
	        T--;
	    }
	}
	catch(Exception e){
	    return ;
	}
}

}
why getting TLE if my code just ran in “0.14” seconds and time limit was “0.5” seconds ??

Please link to your submission.

https://www.codechef.com/submit/SVRT

Are you Asking For this link?

what I think you are talking about this problem:
problem link: Contest Page | CodeChef

This problem is simple Math problem.
My solution link: Solution: 44346207 | CodeChef

Feel free to ask anything.
Thanks.

1 Like

yes , but can you tell why i am getting TLE . As my solution is also running just showing TLE at submission time.

Surely, Please provide link for your code so that I can figure out easily.

1 Like

Someone needs to create a “how to link to your submission” Tutorial as a counterpart to [Tutorial] CoLoR format the Code!, as people always seem to get it wrong.

You can try to use a faster i/o like BufferedReader instead of Scanner.