atcoder#ARC152A. [ARC152A] Seat Occupation
[ARC152A] Seat Occupation
Score : points
Problem Statement
There is a row of chairs. Now, groups of people will come and take seats in order. Each group consists of one or two people, and the -th group to come consists of people. The total number of people equals .
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 groups can take seats.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
If it is guaranteed that all groups can take seats, print Yes
; otherwise, print No
.
2 4
2 2
No
Let us number the chairs , , , from left to right.
If the first group of two people takes chairs and , the next group of two people cannot take seats and will leave.
Thus, it is not guaranteed that all groups can take seats, so you should print No
.
3 4
1 2 1
Yes
No matter what chairs they choose, everyone can always take a seat.