I am unable to understand why CodeChef compiler is giving me wrong output while solving https://www.codechef.com/problems/ATM2. When I tried every other online compiler as well as GNU compiler I was getting required output.
My code:
#include <stdio.h>
int main(void)
{
int t;
scanf("%d",&t);
for(int i=0;i<t;i++)
{
int n,k;
scanf("%d %d",&n,&k);
int a[n];
char o[n];
for(int j=0;j<n;j++)
{
scanf("%d",&a[j]);
if(a[j]>k || k==0)
{
o[j]='0';
}
else
{
k=k-a[j];
o[j]='1';
}
}
printf("%s\n",o);
}
return 0;
}