what is wrong with this Nuclear Reactor(Nukes) code it showing error for two test cases

import java.util.*;
class nukes
{
public static void main(String args[])
{
int i,j,a,n,k,l;
Scanner sc =new Scanner(System.in);
a=sc.nextInt();
n=sc.nextInt();
k=sc.nextInt();
int c[] = new int[k];
for(i=0;i<c.length;i++)
c[i]=0;
for(i=0;i<a;i++)
{
for(j=0;j<c.length;j++)
{
if(c[j]<n)
{
c[j]+=1;
for(k=0;k<=j-1;k++)
{
c[k]=0;
}
break;
}
}
}
for(i=0;i<c.length;i++)
System.out.print(c[i] + " ");
}
}

In general it’s better if you share a link to your code (link) and use the question space to describe what your algorithm is. Then everything is in useful places with proper formatting.

Have you considered what happens when all the “reactors” are full and another particle comes in? What should happen is that all reactors become empty, but I don’t see a mechanism for that to happen in your code. This is probably giving your “wrong answer” issue.

Test case:

8 1 3

should give

0 0 0

As for the “time limit exceeded” problem - that is because you are modeling the process directly. The number of particles in the first reactor follows a simple pattern; once you have this you should be able to see how to make it work for the other reactors also.