I'm trying to solve this problem in Java but it gives me an error. The reason is that I can't achieve processing 2.5MB of input data per second at runtime. I want to know is there any way to speed up my code?
public class Main {
final static int size = 5000;
static int[] result = new int[size];
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int k = input.nextInt();
int divided = 0;
BufferedReader bi = new BufferedReader(new InputStreamReader(System.in));
try {
while (n-- > 0) {
result[n] = Integer.parseInt(bi.readLine());
if (result[n] % k == 0)
divided++;
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(divided);
input.close();
}
}