Read problems statements in [Hindi], [Mandarin Chinese],  [Vietnamese], and [Bengali] as well.

A semester in Chef's University has $120$ working days. The University's requirement is that a student should be present for at least $75\%$ of the working days in the semester. If not, the student is failed.

Chef has been taking a lot of holidays, and is now concerned whether he can pass the attendance requirement or not. $N$ working days have already passed, and you are given $N$ bits - $B_{1}$, $B_{2}$, ..., $B_{N}$. $B_{i}$ = $0$ denotes that Chef was absent on the $i^{th}$ day, and $B_{i}$ = $1$ denotes that Chef was present on that day.

Can Chef hope to pass the requirement by the end of the semester?

------ Input: ------

First line will contain $T$, the number of testcases. Then the testcases follow. 
Each testcase contains two lines of input.
The first line of each testcase contains a single integer, $N$, the number of days till now.
The second line of each testcase contains a string $B$ of length $N$ where $B_{i}$ represents the status of the $i^{th}$ day.

------ Output: ------
For each testcase, output the answer in a single line - "YES" if Chef can pass the attendance requirement and "NO" if not.

------ Constraints  ------
$1 ≤ T ≤ 10$
$1 ≤ N ≤ 120$
$0 ≤ B_{i} ≤ 1$

----- Sample Input 1 ------ 
3

50

00000000000000000000000000000000000000000000000000

50

01010101010101010101010101010101010101010101010101

2

01
----- Sample Output 1 ------ 
NO

YES

YES
----- explanation 1 ------ 
For Case 1, even if Chef attends all the remaining 70 days, he'll only have an attendance percentage of $70/120$ = $58.33\%$ which is less than $75\%$.

For Case 2, maximum attendance possible is $79.167\%$ which is more than $75\%$.

For Case 3, maximum attendance possible is $99.167\%$ which is more than $75\%$.

Source: codechef | Difficulty: EASY
Tags: Mathematics

Complete search


Solutions:
t = int(input())
for i in range(t):
	T = 120
	d_t_n = int(input())
	b = input()
	count = 0
	for j in b:
		if j == '1':
			count += 1
	if count + (T - d_t_n) >= 90:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = (120 - s.count('0')) / 120 * 100
	if a >= 75:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	t = 120
	d = int(input())
	b = input()
	count = 0
	for i in b:
		if i == '1':
			count += 1
	if count + (t - d) >= 90:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	N = int(input())
	B = input()
	count = 0
	for j in range(N):
		if B[j] == '0':
			count = count + 1
	if (120 - count) / 120 >= 0.75:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	b = input()
	countp = 0
	countp = b.count('1')
	if (countp + 120 - n) / 120 * 100 >= 75:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	a = input()
	n = input()
	onecount = n.count('1')
	if int(onecount) + (120 - int(a)) >= 90:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	s = input()
	if (s.count('1') + 120 - n) / 120 < 0.75:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	days_so_far = int(input())
	attendance = input()
	school_days_attended = attendance.count('1')
	present = school_days_attended + (120 - days_so_far)
	if present / 120 >= 0.75:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = []
	l[:] = s
	c = l.count('1')
	c += 120 - n
	if c / 120 * 100 < 75:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	b = input()
	c = b.count('1')
	if c + (120 - n) >= 90:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = input()
	count = 0
	for i in range(n):
		if a[i] == '1':
			count += 1
	absent = n - count
	x = 120 - absent
	if x >= 90:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = int(input())
	b = input()
	c = 0
	for i in b:
		if i == '0':
			c = c + 1
	d = 120 - c
	e = d / 120 * 100
	if e >= 75:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = input()
	l1 = []
	p = 120 - n
	for i in l:
		if i == '1':
			l1.append(i)
	present = p + len(l1)
	c = present / 120 * 100
	if c >= 75:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	b = input()
	mindays = 90
	daysremain = 120 - n
	fail = 90 > b.count('1') + daysremain
	print('NO' if fail else 'YES')


from collections import Counter
t = int(input())
for i in range(t):
	n = int(input())
	b = input()
	x = Counter(b)
	n1 = x['1']
	n0 = x['0']
	m = 120 - n
	a = m + n1
	if a / 120 * 100 >= 75:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	b = str(input())
	count = 0
	for i in range(0, n):
		if b[i] == '1':
			count = count + 1
	a = 120 - n
	s = a + count
	if s / 120 >= 0.75:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	s = input()
	a = s.count('0')
	if 120 - a >= 90:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	b = int(input())
	hdr = input()
	for j in range(b):
		st = hdr.count('1')
		c = 120 - b + st
		d = c / 120 * 100
	if d >= 75:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().strip()))
	c = 0
	for i in range(n):
		if arr[i] == 1:
			c += 1
	if c + 120 - n < 90:
		print('NO')
	else:
		print('YES')


for x in range(int(input())):
	n = int(input())
	a = input()
	b = len(a)
	c = 0
	for i in range(len(a)):
		if a[i] == '1':
			c = c + 1
	if 120 - n + c >= 90:
		print('YES')
	else:
		print('NO')


x = int(input())
for i in range(x):
	n = int(input())
	a = input()
	z = a.count('0')
	b = 120 - z
	c = b / 120 * 100
	if c < 75:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	a = int(input())
	x = input()
	q = x.count('0')
	w = x.count('1')
	e = 120 - q
	f = e / 120 * 100
	if f >= 75:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	a = int(input())
	s = input()
	c = s.count('1')
	if c + (120 - a) >= 90:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = int(input())
	att = list(input())
	d = 120 - a
	e = a - att.count('0')
	print('YES') if (e + d) / 120 * 100 >= 75 else print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	x = s.count('1')
	a = 120 - n
	y = x + a
	if y >= 90:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	working_days = int(input())
	attendance = str(input())
	remaining_days = 120 - working_days
	days_present = attendance.count('1')
	if (days_present + remaining_days) / 120 * 100 >= 75:
		print('YES')
		pass
	else:
		print('NO')
		pass
	pass


for _ in range(int(input())):
	a = int(input())
	b = input()
	c = 0
	for i in b:
		if i == '1':
			c += 1
	if 120 - a + c >= 90:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	k = int(input())
	l = input()
	o = l.count('1')
	p = k - o
	j = 120 - p
	if j >= 90:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	d = int(input())
	s = input()
	c = 0
	for j in s:
		if j == '1':
			c += 1
	x = d - c
	p = 120 - x
	if p / 120 * 100 >= 75:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	str1 = input()
	lst = list(str1)
	sum1 = 0
	for i in range(n):
		if lst[i] == '1':
			sum1 += 1
	ans = sum1 + 120 - n
	if ans * 100 / 120 >= 75:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	p = s.count('1')
	if (p + (120 - n)) * 100 / 120 >= 75:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	l = int(input())
	s = input()
	a = s.count('1')
	print('YES' if (a + 120 - l) * 100 / 120 >= 75 else 'NO')


for i in range(int(input())):
	n = int(input())
	k = [int(x) for x in input()]
	if k.count(1) + (120 - len(k)) >= 90:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	c = 0
	for x in s:
		if x == '1':
			c = c + 1
	if (120 - n + c) / 120 * 100 >= 75:
		print('YES')
	else:
		print('NO')


t = int(input())
while t != 0:
	x = int(input())
	y = input()
	count_zero = y.count('0')
	count_one = y.count('1')
	total_present = 120 - count_zero
	ans = total_present / 120 * 100
	if ans >= 75:
		print('YES')
	else:
		print('NO')
	t -= 1


for i in range(int(input())):
	n = int(input())
	s = input()
	l = list(s)
	c = 0
	for i in l:
		if i == '1':
			c += 1
	if 120 + c - n >= 90:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input()))
	a = l.count(1)
	if (120 - n + a) * 100 / 120 >= 75:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	zeros = s.count('0')
	if 120 - zeros < 90:
		print('NO')
	else:
		print('YES')


q = int(input())
while q > 0:
	n = int(input())
	s = input()
	s = list(s)
	c0 = s.count('0')
	c1 = s.count('1')
	x = (120 - c0) / 120 * 100
	if x < 75:
		print('NO')
	else:
		print('YES')
	q = q - 1


for _ in range(int(input())):
	x = int(input(' '))
	y = int(input(' '))
	i = 0
	s = sum(map(int, str(y)))
	res = s + (120 - x)
	if res >= 90:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	l = int(input())
	s = list(input())
	a = s.count('1') + (120 - l)
	if a / 120 >= 0.75:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	s = input()
	one = s.count('1')
	if 120 - n + one >= 90:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for i in range(t):
	com = int(input())
	days = input()
	count = 0
	for j in days:
		if j == '1':
			count += 1
	posible_days = count + (120 - com)
	per = posible_days * 100 / 120
	if per >= 75:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	fd = int(input())
	s = input()
	pd = 0
	for x in s:
		if x == '1':
			pd += 1
	rd = 120 - fd
	if (rd + pd) / 120 * 100 >= 75:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	c = 0
	for i in range(n):
		if s[i] == '1':
			c += 1
	ab = n - c
	x = 120 - ab
	if x >= 90:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input()))
	value = b.count(1)
	if (120 - n + value) / 120 * 100 >= 75:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	length = int(input())
	s = input()
	coun1 = s.count('1')
	if coun1 + (120 - length) >= 90:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = int(input())
	b = input()
	c = 0
	for j in b:
		if j == '1':
			c += 1
	d = c + 120 - a
	if d / 120 >= 0.75:
		print('YES')
	else:
		print('NO')