Help me in solving DIET problem

The code is giving correct answers on other compilers but the output being returned on this platform is completely different

My code

#include <stdio.h>

int main(void) {
	int t,n,k,i,j,c,m;
	scanf("%d",&t);
	for(i=0;i<t;i++){
	    c=0;
	    scanf("%d %d",&n,&k);
	    int a[n];
	    for(j=0;j<n;j++){
	        scanf("%d",&a[j]);
	        a[j]+=c;
	        if(a[j]>=k){
	            c=a[j]-k;
	            m++;
	        }
	            else{
	                m=0;
	                break;}}
	                if(m==n)
	                printf("YES\n");
	                else
	                printf("NO %d\n",j+1);
	}
	return 0;
}

Problem Link: DIET Problem - CodeChef

@ph_9504
two mistakes first u have to initialize m=0 as well and second first u have to scan the whole array then apply operation like if u haven’t scan the whole array it will throw the garbage values for rest test cases.
i have corrected it in your code.

include <stdio.h>

int main(void) {
int t,n,k,i,j,c,m;
scanf(“%d”,&t);
for(i=0;i<t;i++){
c=0;
m=0;
scanf(“%d %d”,&n,&k);
int a[n];
for(int j=0;j<n;j++)
{
scanf(“%d”,&a[j]);
}
for(j=0;j<n;j++){

        a[j]+=c;
        if(a[j]>=k){
            c=a[j]-k;
            m++;
        }
            else{
                m=0;
                break;}}
                if(m==n)
                printf("YES\n");
                else
                printf("NO %d\n",j+1);
}
return 0;

}