AtCoder Regular Contest 152
翻译中…
Problem Statement
翻译中…
There is a row of $L$ chairs. Now, $N$ groups of people will come and take seats in order. Each group consists of one or two people, and the $i$-th group to come consists of $a_i$ people. The total number of people equals $L$.
翻译中…
Each group will randomly choose unoccupied chairs where all group members 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 can take seats.
翻译中…
Constraints
翻译中…
$1\leq N\leq 2\times 10^5$$1\leq a_i\leq 2$$L=a_1 +a_2 +\ldots +a_N$- All values in the input are integers.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N L
a_1 a_2 \ldots a_N
翻译中…
Output
翻译中…
If it is guaranteed that all $N$ groups can take seats, print Yes; otherwise, print No.
翻译中…
样例
Input #1
2 4
2 2
Output #1
No
Let us number the chairs $1$, $2$, $3$, $4$ from left to right. If the first group of two people takes chairs $2$ and $3$, the next group of two people cannot take seats and will leave. Thus, it is not guaranteed that all $N$ groups can take seats, so you should print `No`.
Input #2
3 4
1 2 1
Output #2
Yes
No matter what chairs they choose, everyone can always take a seat.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。