def seat_arrangement(n, r, a):
"""
This function determines whether it is guaranteed that all N groups(both single and couple) can take seats in an auditorium that contains a row of R seats.
Args:
n: The number of groups.
r: The number of seats in the row.
a: An array containing 1 or 2. Where 1 indicate single people and 2 indicate couple.
Returns:
"Yes" if it is guaranteed that all N groups can take seats, otherwise "No".
"""
Count the number of couples and singles.
couples = a.count(2)
singles = n - couples
Calculate the minimum number of seats required.
min_seats = couples * 2 + singles
Return "Yes" if the number of seats is greater than or equal to the minimum number of seats required, otherwise "No".
return "Yes" if r >= min_seats else "No"
if name == "main":
Read the input.
n, r = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
Print the output.
print(seat_arrangement(n, r, a))
Seat Arrangement
Prepbudy is hosting a function in an auditorium that contains a row of R seats. The people coming to the function are either couples or single.
You are given an N size array containing 1 or 2. Where 1 indicate single people and 2 indicate couple.
Each couple and single person will randomly choose unoccupied chairs where all couples can sit consecutively, and occupy those chairs. However, if there are not enough consecutive unoccupied chairs, they will leave without taking seats.
Determine whether it is guaranteed that all N groups(both single and couple) can take seats.
Input format
The first line contains a single integer N and R the number of groups and the number of seats in the row.
The next line contains N space-separated integers a_1,a_2....a_N.
Output format
If it is guaranteed that all N groups can take seats, print "Yes"; otherwise, print "No".
Constraints
1 \leq N \leq 10^5
1 \leq a_i \leq 2
L=a_1+a_2+…+a_N
Time Limit
1 second
Example
Input 1
2 4
2 2
Output 1
No
Explanation
Let us number the chairs 1, 2, 3, 4 from left to right. If the first couple takes chairs for 2 and 3, the next couple cannot take seats and will leave. Thus, it is not guaranteed that all N groups can take seats, so you should print "No".