Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well.

There is an ATM machine. Initially, it contains a total of $K$ units of money. $N$ people (numbered $1$ through $N$) want to withdraw money; for each valid $i$, the $i$-th person wants to withdraw $A_{i}$ units of money.

The people come in and try to withdraw money one by one, in the increasing order of their indices. Whenever someone tries to withdraw money, if the machine has at least the required amount of money, it will give out the required amount. Otherwise, it will throw an error and not give out anything; in that case, this person will return home directly without trying to do anything else.

For each person, determine whether they will get the required amount of money or not.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains two space-separated integers $N$ and $K$.
The second line contains $N$ space-separated integers $A_{1}, A_{2}, \dots, A_{N}$.

------  Output ------
For each test case, print a single line containing a string with length $N$. For each valid $i$, the $i$-th character of this string should be '1' if the $i$-th person will successfully withdraw their money or '0' otherwise.

------  Constraints ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$1 ≤ A_{i} ≤ 1,000,000$ for each valid $i$
$1 ≤ K ≤ 1,000,000$

----- Sample Input 1 ------ 
2
5 10
3 5 3 2 1
4 6
10 8 6 4
----- Sample Output 1 ------ 
11010
0010
----- explanation 1 ------ 
Example case 1: The ATM machine initially contains $10$ units of money. The first person comes and withdraws $3$ units, so the amount remaining in the machine is $7$. Then the second person withdraws $5$ units and the remaining amount is $2$. The third person wants to withdraw $3$ units, but since there are only $2$ units of money in the machine, it throws an error and the third person must leave without getting anything. Then the fourth person withdraws $2$ units, which leaves nothing in the machine, so the last person does not get anything.

Example case 2: The ATM machine initially contains $6$ units of money, so it cannot give anything to the first and second person. When the third person comes, it gives them all the money it has, so the last person does not get anything either.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for p in a:
		if k >= p:
			k -= p
			print('1', end='')
		else:
			print('0', end='')
	print()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	result = ''
	for j in range(n):
		if k >= a[j]:
			k -= a[j]
			result += '1'
		else:
			result += '0'
	print(result)


T = int(input())
for tc in range(T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	current_amount = k
	result = []
	for i in range(n):
		if current_amount >= a[i]:
			result.append(1)
			current_amount = current_amount - a[i]
		else:
			result.append(0)
	print(''.join(map(str, result)))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	f = ''
	for i in range(n):
		if k >= l[i]:
			k -= l[i]
			f += '1'
		else:
			f += '0'
	print(f)


t = int(input())
for i in range(t):
	s = ''
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	for i in range(n):
		if k >= A[i]:
			k -= A[i]
			s = s + '1'
		else:
			s = s + '0'
	print(s)


n = int(input())
c = []
while n > 0:
	(n1, n2) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in l:
		if n2 >= i:
			c.append('1')
			n2 = n2 - i
		else:
			c.append('0')
	x = ''.join(c)
	print(x)
	c.clear()
	n = n - 1


test = int(input())
res = []
ans = ''
while test:
	test = test - 1
	(N, K) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	for i in A:
		if K - i >= 0:
			ans = ans + '1'
			K = K - i
		else:
			ans = ans + '0'
	res.append(ans)
	ans = ''
for i in res:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in range(n):
		if l[i] <= k:
			k = k - l[i]
			l[i] = 1
		else:
			l[i] = 0
	for i in range(n):
		print(l[i], end='')
	print()


T = int(input())
for t in range(T):
	(N, K) = map(int, input().split())
	sequence = list(map(int, input().split()))
	result = []
	for i in range(N):
		if sequence[i] > K:
			result.append('0')
		else:
			K -= sequence[i]
			result.append('1')
	print(''.join(result))


for _ in range(int(input())):
	(n, mon) = map(int, input().split())
	l = list(input().split())
	for i in range(n):
		l[i] = int(l[i])
	ns = ''
	for i in range(n):
		if l[i] <= mon:
			ns += '1'
			mon -= l[i]
		else:
			ns += '0'
	print(ns)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	str = ''
	for i in range(n):
		if a[i] <= k:
			str += '1'
			k -= a[i]
		else:
			str += '0'
	print(str)
	t -= 1


for _ in range(int(input())):
	(n, k) = input().split()
	N = int(n)
	K = int(k)
	A = list(input().split())
	response = ''
	for i in range(N):
		A[i] = int(A[i])
		if K >= A[i]:
			response += '1'
			K = K - A[i]
		else:
			response += '0'
	print(response)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	l = list(map(int, input().split()))
	c = y
	s = ''
	for i in range(x):
		if l[i] <= c:
			c -= l[i]
			s += '1'
		else:
			s += '0'
	print(s)


T = int(input())
for i in range(0, T):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	sum = 0
	for i in range(0, n):
		if a[i] + sum <= k:
			sum = sum + a[i]
			print(1, end='')
		else:
			print(0, end='')
			continue
	print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	t = list(input().split())
	for i in range(n):
		t[i] = int(t[i])
	l = ''
	for i in range(n):
		if t[i] <= m:
			l += '1'
			m -= t[i]
		else:
			l += '0'
	print(l)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	t = ''
	for i in c:
		k = b - i
		if k >= 0:
			t = t + '1'
			b = k
		else:
			t = t + '0'
	print(t)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))[:n]
	s = ''
	for j in range(n):
		if l[j] > k:
			s += '0'
			j = j + 1
		else:
			k = k - l[j]
			s += '1'
	print(s)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	for amt in arr:
		if amt <= m:
			print('1', end='')
			m -= amt
		else:
			print('0', end='')
	print()


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	l = [int(x) for x in input().split()]
	s = ''
	for i in range(a):
		if l[i] <= b:
			s += '1'
			b -= l[i]
		else:
			s += '0'
	print(s)


for z in range(int(input())):
	(n, a) = map(int, input().split())
	b = list(map(int, input().split()))
	for i in b:
		if a >= i:
			a = a - i
			print(1, end='')
		else:
			print(0, end='')
	print()


T = int(input())
for i in range(T):
	t = input()
	l = t.split(' ')
	N = int(l[0])
	K = int(l[1])
	t2 = input()
	l2 = t2.split(' ')
	for j in l2:
		if int(j) <= K:
			print('1', end='')
			K = K - int(j)
		else:
			print('0', end='')
	print()


for _ in range(int(input())):
	(N, K) = input().split()
	K = int(K)
	a = [int(i) for i in input().split(' ')]
	ans = ''
	for i in range(int(N)):
		if K - a[i] >= 0:
			ans += '1'
			K -= a[i]
		else:
			ans += '0'
	print(ans)


t = int(input())
for x in range(t):
	p = ''
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in a:
		if i <= k:
			k -= i
			p = p + '1'
		else:
			p = p + '0'
	print(p)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	list1 = list(map(int, input().split()))
	for x in range(a):
		if list1[x] <= b:
			b -= list1[x]
			print(1, end='')
		else:
			print(0, end='')
	print('')


T = int(input())
for i in range(T):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	result = ''
	for i in range(N):
		if K >= A[i]:
			K -= A[i]
			result += '1'
		else:
			result += '0'
	print(result)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	rem = k
	for i in range(n):
		if a[i] <= rem:
			rem = rem - a[i]
			print('1', end='')
		else:
			print('0', end='')
	print()


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	for i in A:
		if i <= K:
			K -= i
			print(1, end='')
		else:
			print(0, end='')
	print()


for _e in range(int(input())):
	(n, k) = map(int, input().split())
	t = [int(a) for a in input().split()]
	txt = ''
	for i in t:
		txt += '1' if i <= k else '0'
		k -= i if i <= k else 0
	print(txt)


for t in range(int(input())):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	strr = ''
	for x in range(len(A)):
		if A[x] <= K:
			K = K - A[x]
			strr = strr + str('1')
		else:
			strr = strr + str('0')
	print(strr)


for _ in range(int(input())):
	(n, money) = map(int, input().split())
	L = list(input().split())
	for i in range(n):
		L[i] = int(L[i])
	ns = ''
	for i in range(n):
		if L[i] <= money:
			ns += '1'
			money -= L[i]
		else:
			ns += '0'
	print(ns)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	n_int = list(input().split(' '))
	res = ''
	for j in range(n):
		if int(n_int[j]) <= k:
			res = res + '1'
			k = k - int(n_int[j])
		else:
			res = res + '0'
	print(res)


for _ in range(int(input())):
	(n, u) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = ''
	rem = u
	for i in l:
		if i <= rem:
			ans += '1'
			rem = rem - i
		else:
			ans += '0'
			continue
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = list(map(int, input().split()))
	a = ' '
	for i in range(n):
		if d[i] <= k:
			a += '1'
			k = k - d[i]
		else:
			a += '0'
			continue
	print(a)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	L = list(input().split())
	for i in range(n):
		L[i] = int(L[i])
	res = ''
	for i in range(n):
		if L[i] <= k:
			res += '1'
			k -= L[i]
		else:
			res += '0'
	print(res)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	lst = list(map(int, input().split()))
	for i in range(len(lst)):
		if k >= lst[i]:
			k = k - lst[i]
			print('1', end='')
		else:
			print('0', end='')
	print()


tc = int(input())
for i in range(tc):
	(n, k) = map(int, input().split())
	withdraw = list(map(int, input().split()))
	balance = k
	output = []
	for j in range(n):
		if balance >= withdraw[j]:
			output.append('1')
			balance -= withdraw[j]
		else:
			output.append('0')
	print(''.join(output))
	output = []


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	k = list(input().split())
	b = ''
	for i in range(n):
		k[i] = int(k[i])
		if k[i] <= m:
			b = b + '1'
			m = m - k[i]
		else:
			b = b + '0'
	print(b)


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))
	check_money = None
	money_left = K
	last_output = ''
	for i in A:
		if money_left >= i:
			last_output = last_output + '1'
			money_left = money_left - i
		elif money_left == 0 or money_left < i:
			last_output = last_output + '0'
		else:
			last_output = last_output + '0'
	print(last_output)


def atmMachine(a, k):
	string = str()
	for _ in a:
		if k - _ >= 0:
			string += '1'
			k -= _
		else:
			string += '0'
	print(string)
for i in range(int(input())):
	(N, K) = map(int, input().split())
	A = list(map(int, input().split()))[:N]
	atmMachine(A, K)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	ans = []
	for i in range(n):
		if l[i] <= k:
			k = k - l[i]
			ans.append('1')
		else:
			ans.append('0')
	print(''.join(ans))


for T in range(int(input())):
	(n, k) = map(int, input().split())
	n = list(map(int, input().split()))
	x = ''
	for i in n:
		if k - i >= 0:
			x += '1'
			k -= i
		else:
			x += '0'
	print(x)


for case in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	s = str()
	for i in range(n):
		if a[i] <= k:
			k -= a[i]
			s += '1'
		else:
			s += '0'
	print(s)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	for j in range(x):
		if a[j] > y:
			print('0', end='')
			continue
		else:
			print('1', end='')
			y = y - a[j]
	print('\n')


t = int(input())
for i in range(t):
	(person, money) = map(int, input().split())
	permoney = list(map(int, input().split()))
	out = ''
	for j in range(person):
		if money >= permoney[j]:
			money -= permoney[j]
			out = out + '1'
		else:
			out = out + '0'
	print(out)


n = int(input())
l = []
ll = []
j = 0
for i in range(n):
	(x, y) = map(int, input().split())
	l = list(map(int, input().split()))
	for i in range(x):
		if l[i] <= y:
			print(1, end='')
			y = y - l[i]
		else:
			print(0, end='')
	print()


t = int(input())
for i in range(t):
	(y, z) = map(int, input().split())
	x = list(map(int, input().split()))
	for i in range(y):
		if z - x[i] >= 0:
			z = z - x[i]
			print(1, end='')
		else:
			print(0, end='')
	print()


for j in range(int(input())):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	for x in a:
		if x <= k:
			print(1, end='')
			k = k - x
		else:
			print(0, end='')
	print()


t = input()
for _ in range(int(t)):
	(n, k) = map(int, input().split())
	N = input().split()
	raw = ''
	for i in range(n):
		if k >= int(N[i]):
			k = k - int(N[i])
			raw = raw + '1'
		else:
			raw = raw + '0'
	print(raw)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = [int(c) for c in input().split()]
	count = str()
	sum = 0
	for i in range(a):
		if c[i] <= b - sum:
			count += '1'
			sum += c[i]
		else:
			count += '0'
	print(count)


for i in range(int(input())):
	(a, b) = map(int, input().split(' '))
	withdraw_amt = input().split(' ')
	opt = ''
	for j in range(a):
		if b >= int(withdraw_amt[j]):
			b = b - int(withdraw_amt[j])
			opt = opt + '1'
		else:
			opt = opt + '0'
	print(opt)


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	l1 = []
	for j in l:
		if j <= k:
			l1.append(1)
			k = k - j
		else:
			l1.append(0)
	s = ''.join([str(j) for j in l1])
	print(s)


for _ in range(int(input())):
	(person, tot_money) = map(int, input().split())
	l = []
	res = []
	w = input().split()
	for get in w:
		l.append(int(get))
	for i in l:
		if i <= tot_money:
			res.append('1')
			tot_money = tot_money - i
		else:
			res.append('0')
	op = ''.join(res)
	print(op)


def can_withdraw(balance, amount):
	return balance >= amount

def atm_withdrawals():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		a = list(map(int, input().split()))
		result = ''
		balance = k
		for i in range(n):
			if can_withdraw(balance, a[i]):
				balance -= a[i]
				result += '1'
			else:
				result += '0'
		print(result)
atm_withdrawals()


t = int(input())
for i in range(t):
	(N, k) = map(int, input().split())
	l = list(map(int, input().split()))
	c = ''
	for i in range(N):
		if l[i] <= k:
			k -= l[i]
			c += '1'
		else:
			c += '0'
	print(c)


t = int(int(input()))
for i in range(t):
	ans = []
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	for i in range(n):
		if a[i] <= k:
			ans.append(1)
			k -= a[i]
		else:
			ans.append(0)
	x = ''.join(map(str, ans))
	print(x)


for i in range(int(input())):
	A = []
	ans = ''
	(N, K) = map(int, input().split())
	A.append(input().split())
	for j in A:
		for m in j:
			if m == ' ':
				pass
			elif K >= int(m):
				ans += '1'
				K -= int(m)
			else:
				ans += '0'
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	ans = ''
	money = k
	for i in range(n):
		if a[i] <= money:
			money -= a[i]
			ans += '1'
		else:
			ans += '0'
	print(ans)


T = int(input())
a = []
for i in range(T):
	first = input().split()
	N = int(first[0])
	K = int(first[1])
	second = input().split()
	l = K
	for j in range(N):
		m = int(second[j])
		if m <= l:
			l -= m
			print('1', end='')
		else:
			print('0', end='')
			continue
	print('\n')


for _ in range(int(input())):
	nk = list(map(int, input().split()))
	an = list(map(int, input().split()))
	(c, out) = (0, '')
	for i in range(nk[0]):
		c += an[i]
		if c <= nk[1]:
			out += '1'
		else:
			out += '0'
			c -= an[i]
	print(out)


t = int(input())
for i in range(t):
	(ppl, amount) = list(map(int, input().split()))
	debit = list(map(int, input().split()))
	res = ''
	for i in range(0, ppl):
		if debit[i] <= amount:
			res = res + '1'
			amount -= debit[i]
		else:
			res = res + '0'
	print(res)


def ATM_machine(n, k, A: list):
	ret = []
	for i in range(n):
		if A[i] <= k:
			k = k - A[i]
			ret.append('1')
		else:
			ret.append('0')
	return ''.join(ret)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	print(ATM_machine(n, k, A))


T = int(input())
for tc in range(T):
	(n, k) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	s = ''
	for i in range(n):
		if k >= a[i]:
			s = s + '1'
			k = k - a[i]
		else:
			s = s + '0'
	print(s)


t = int(input())
for i in range(t):
	(p, m) = map(int, input().split())
	A = list(map(int, input().split()))
	s = ''
	for j in range(p):
		if A[j] <= m:
			s = s + '1'
			m = m - A[j]
		else:
			s = s + '0'
	print(s)


t = int(input())
vowels = ['a', 'e', 'i', 'o', 'u']
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	i = 0
	while i < n:
		if arr[i] <= k:
			k -= arr[i]
			print(1, end='')
		else:
			print(0, end='')
		i += 1
	print()