STPAR - Street Parade

题意翻译

## 题目描述 可以肯定的是,今年夏天的街头游行中,love mobiles还会再次上路。每年,组织者都要为这些装饰好的卡车制定一个固定的订单。经验告诉他们要腾出一条小街,以便让卡车驶入秩序。这条小巷太窄了,没有两辆车能通过。因此,最后进入小街的爱情车一定要先离开小街。因为卡车和铲车靠得很近,卡车不能开回来再进入侧街或进近街。你被给予爱的移动的顺序到达。编写一个程序来决定爱情手机是否可以按照组织者希望的顺序排列。 ## 输入格式 - 有几个测试用例。 - 每个测试用例的第一行包含一个数字n,即love mobiles的数量。 - 第二行包含任意顺序的数字1到n。所有的数字都用空格隔开。这些数字表示卡车到达进近街道的顺序。不超过1000辆爱车参加了街头游行。 - 输入以数字0结束。 ## 输出格式 - 对于每个测试用例,您的程序必须输出一行包含一个单词“yes”,如果love mobiles可以在小巷的帮助下重新订购,而在相反的情况下输出一个单词“no”。

题目描述

For sure, the love mobiles will roll again on this summer's street parade. Each year, the organisers decide on a fixed order for the decorated trucks. Experience taught them to keep free a side street to be able to bring the trucks into order. The side street is so narrow that no two cars can pass each other. Thus, the love mobile that enters the side street last must necessarily leave the side street first. Because the trucks and the ravers move up closely, a truck cannot drive back and re-enter the side street or the approach street. You are given the order in which the love mobiles arrive. Write a program that decides if the love mobiles can be brought into the order that the organisers want them to be.

输入输出格式

输入格式


There are several test cases. The first line of each test case contains a single number n, the number of love mobiles. The second line contains the numbers 1 to n in an arbitrary order. All the numbers are separated by single spaces. These numbers indicate the order in which the trucks arrive in the approach street. No more than 1000 love mobiles participate in the street parade. Input ends with number 0.

输出格式


For each test case your program has to output a line containing a single word "yes" if the love mobiles can be re-ordered with the help of the side street, and a single word "no" in the opposite case.

输入输出样例

输入样例 #1

5
5 1 2 4 3 
0

输出样例 #1

yes