当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3700:Missile Defence System

题目描述

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.

输入解释

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.


该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3700

最后修改于 2020-10-29T07:08:27+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 65536