-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOVID19.py
39 lines (35 loc) · 981 Bytes
/
COVID19.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Problem code COVIDLQ
import operator
t=int(input())
def getIndexPositions(listOfElements,element):
indexPosList = []
indexPos = 0
while True:
try:
indexPos = listOfElements.index(element, indexPos)
indexPosList.append(indexPos)
indexPos += 1
except ValueError as e:
break
return indexPosList
def solve():
n=int(input())
numbers=list(map(int,input().split()))[:n]
numberOfOnes=numbers.count(1)
actualDistance=6*numberOfOnes-5
if(len(numbers)<7 and numberOfOnes != 1):
return "NO"
elif(numberOfOnes == 1):
return "YES"
elif(len(numbers) >= actualDistance):
res_list = getIndexPositions(numbers,1)
res = list(map(operator.sub, res_list[1:], res_list[:-1]))
if(all(i >= 6 for i in res)):
return "YES"
else:
return "NO"
else:
return "NO"
for i in range(t):
ans=solve()
print(ans)