1737. Bus Story

单点时限: 2.0 sec

内存限制: 256 MB

”… and they lived happily ever after.”

“But that could not ever happen”, screamed the children lying in bed. “We want something that could really take place somewhere, not just a commercially successful reprint of fairy tales several hundreds of years old”, said a nine year old boy.

Yeah, the times they are a-changing.

“So, let’s play a game” said mother, trying to hide the fact that she has already missed 15 minutes of her favorite soap opera. This has to finish soon! “I will tell you a story and all you need to do is to tell me whether it can be true or not. If you tell me the correct answer, I will let you watch TV instead.” Children quickly agreed and mother started telling a story:

“Once upon a time, there was a bus with some passengers. After it has stopped on a bus stop, a man got inside. On the following stop, 7 people got off and another 4 boarded the bus. …

… and on the terminal stop, two travellers got out, the driver locked the empty bus and went away too.”

After the story was over, the children slowly began to realize what they have agreed upon. Telling whether the story might be true will not be an easy task.

You are given several bus travelling stories, similar to the one above. Each story will mention every change in the number of travellers during some period of time. Your task is to find out for each story whether it could really happen.

输入格式

The input file contains several stories. The stories are separated by a line consisting of the string “NEW STORY”. This string does not occur inside any story.

The driver is not a passenger. He is in the bus during the entire story. Every passenger that boards the bus will travel for at least one stop. Each sentence ends with a period. Events mentioned in different sentences correspond to different bus stops.

输出格式

For each story output a single line containing the string “YES” if the story could be true and “NO” otherwise.

样例

Input
The bus was empty, no people were sitting inside except for the driver. On the next
stop, 2 people boarded and at the same time, 4 of them left bus. The next stop
was terminal, after arrival the driver locked the bus and went away.
NEW STORY
On this stop, 2 people boarded and while 4 left the bus. At the terminal, 3
people left, the driver locked the bus and went away.
Output
NO
YES
Hint:
In the first case, after the first stop the number of passengers would be -2, and this is clearly impossible. In the second case, the story was possible if the bus contained 5 people at the beginning of the story.

1 人解决,1 人已尝试。

1 份提交通过,共有 1 份提交。

8.9 EMB 奖励。

创建: 16 年,7 月前.

修改: 6 年,8 月前.

最后提交: 16 年,7 月前.

来源: IPSC 2007

题目标签