Help me in solving ATM2 problem

My issue

help me in understanding the logic

My code

# cook your dish here

Problem Link: ATM2 Problem - CodeChef

@dhanyashyam

In the given problem, we need to find if N people can withdraw money. The logic I used here was like this;

Initially ATM has k amount of money. For i-th person to be able to withdraw, the amount in the ATM should not go below zero, (k - a[i] >=0).

If money can be successfully withdrawn, we subtract the amount withdrawn from the available money in the ATM,k. The process is repeated N times.

We print 1 if its possible, otherwise we print 0.

#include <stdio.h>

int main(void)
{
    int t,n,k,a[10000],i;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d",&n,&k);
        for(i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            if(k-a[i]>=0)
            {
                k=k-a[i];
                printf("1");
            }
            else    
            {
                printf("0");
            }
        }
        printf("\n");
    }

	return 0;
}