103640: [Atcoder]ABC364 A - Glutton Takahashi
Description
Score : $100$ points
Problem Statement
Takahashi is planning to eat $N$ dishes.
The $i$-th dish he plans to eat is sweet if $S_i =$ sweet
, and salty if $S_i =$ salty
.
If he eats two sweet dishes consecutively, he will feel sick and be unable to eat any more dishes.
Determine whether he can eat all the dishes.
Constraints
- $N$ is an integer between $1$ and $100$, inclusive.
- Each $S_i$ is
sweet
orsalty
.
Input
The input is given from Standard Input in the following format:
$N$ $S_1$ $S_2$ $\vdots$ $S_N$
Output
Print Yes
if Takahashi can eat all the dishes, and No
otherwise.
Sample Input 1
5 salty sweet salty salty sweet
Sample Output 1
Yes
He will not eat two sweet dishes consecutively, so he can eat all the dishes without feeling sick.
Sample Input 2
4 sweet salty sweet sweet
Sample Output 2
Yes
He will feel sick but can still eat all the dishes.
Sample Input 3
6 salty sweet sweet salty sweet sweet
Sample Output 3
No
He feels sick when eating the 3rd dish and cannot eat the 4th and subsequent dishes.
Output
得分:100分
问题陈述
高桥计划吃N道菜。
如果他计划吃的第i道菜是甜的,那么$S_i =$ sweet
,如果是咸的,那么$S_i =$ salty
。
如果他连续吃两道甜菜,他会感到不舒服,并且无法再吃任何菜。
判断他是否可以吃掉所有的菜。
约束条件
- $N$是介于1到100(包含)之间的整数。
- 每个$S_i$是
sweet
或salty
。
输入
输入从标准输入以下格式给出:
$N$ $S_1$ $S_2$ $\vdots$ $S_N$
输出
如果高桥可以吃掉所有的菜,打印Yes
,否则打印No
。
样本输入1
5 salty sweet salty salty sweet
样本输出1
Yes
他不会连续吃两道甜菜,所以他可以在不感到不舒服的情况下吃掉所有的菜。
样本输入2
4 sweet salty sweet sweet
样本输出2
Yes
他会感到不舒服,但仍然可以吃掉所有的菜。
样本输入3
6 salty sweet sweet salty sweet sweet
样本输出3
No
他在吃第3道菜时感到不舒服,无法吃第4道及以后的菜。