Fake Binary stuff (FAKEBIN) Unexpected TLE

This was the least complex code I could create in Java.
Please tell where can the complexity be reduced?
Thanks in advance!

Code :
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
Scanner in = new Scanner(System.in);

	int a = in.nextInt();
	for( int j=0; j<a ; j++){
	int b = in.nextInt();
	int sum =0;
	for (int i =0; i<b ; i++)
	{int h = in.nextInt();
	sum += h ;


Here’s the link for my solution: https://www.codechef.com/viewsolution/24033825
Here’s the link for the problem: https://www.codechef.com/INTL2019/problems/FAKEBIN

Scanner class is very slow for competitive coding in java.

Refer below link for alternate input methods.

1 Like