ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Unsorted > задача:


51106 - Polar Bear

Гость
• Вопросы к жюри (1)

Задачи раздела

• 50902 - Translate Score into Grade
• 50938 - Translate Score into Grade
• 50890 - Convert Celsius to Fahrenheit
• 50958 - Number of Passengers in Train
• 50889 - Convert to Minutes and Sec...
• 50952 - Print All Numbers from N d...
• 50900 - Put the Numbers in Descend...
• 50884 - Area and Perimeter Of The ...
• 51106 - Polar Bear
• 51109 - Integer to English
• 51110 - The area of a circle
• 51108 - First Unique Character
• 50899 - How Many Years
• 50551 - Kamelot
• 50590 - Бронзовый призёр
• 50602 - День рождения Иванова
• 50603 - Ездец

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.

Polar Bear

Question: Limak is a little polar bear, who loves eating cookies and drinking milk. For this reason he often visits Chef's kitchen.

Limak is going to spend N minutes in the kitchen. Each minute he either eats a cookie or drinks milk. Cookies are very sweet and thus Limak's parents have instructed him, that after eating a cookie, he has to drink milk in the next minute.

You are given whether he ate a cookie or drank milk in each of the N minutes. Your task is to check if Limak followed his parents' instructions. That is, you need to verify whether after each eaten cookie he drinks milk in the next minute. Print "YES" or "NO" for each test case accordingly.

Input specification: The first line of each test case contains an integer N denoting the number of minutes. The second line of a test case contains N space-separated strings S1, S2, ..., SN. The string Si is either "cookie" (if Limak eats a cookie in the i-th minute) or "milk" (otherwise).

Output specification: Output a single line containing the answer "YES" if Limak followed his parents' instructions., and "NO" otherwise, without the quotes.

Constraints 1 ≤ N ≤ 50

Sample Input Sample Output
7
cookie milk milk cookie milk cookie milk
YES
5
cookie cookie milk milk milk
NO
4
milk milk milk milk
YES
1
cookie
NO

Explanation: Test case 1. Limak is in the kitchen for 7 minutes. He eats three cookies and after each of them he indeed drinks milk in the next minute. The answer is "YES".
Test case 2. Limak is in the kitchen for 5 minutes. In the first minute he eats a cookie and in the second minute he eats a cookie again, instead of drinking milk. The answer is "NO".
Test case 3. Here Limak doesn't eat any cookies. The answer is "YES" because the condition is satisfied (there is no situation when Limak eats a cookie but doesn't drink milk in the next minute).
Test case 4. Limak eats a cookie and doesn't drink milk in the next minute so the answer is "NO".



Для отправки решений необходимо выполнить вход.

www.contester.ru