问题 AN: Misssile Defending System
内存限制:128 MB
时间限制:3.000 S
评测方式:文本比较
命题人:
提交:4
解决:3
题目描述
To play against the threats of malicious countries nearby, Country R has updated their missile defence system. The new type system can bring down a series of missiles as long as they are coming in ascending order by altitude or descending order by altitude.
Given the heights of a sequence of coming missiles, the general wants to know how many sets of the new type systems are needed to bring down all of them.
Given the heights of a sequence of coming missiles, the general wants to know how many sets of the new type systems are needed to bring down all of them.
输入
The input consists of several test cases. The first line of each test case contains an integer n(1≤n≤50). The next line contains n different integers indicating the heights.
输出
For each test case output a single line containing the number of systems needed.
样例输入 复制
5
3 5 2 4 1
0
样例输出 复制
2
提示
Two sets of systems are needed for the sample. One brings down 3, 4 and the other brings down 5, 2, 1.