#P10490. Missile Defence System
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 . The next line contains n different integers indicating the heights.
输出格式
For each test case output a single line containing the number of systems needed.For each test case output a single line containing the number of systems needed.
题目大意
【题目描述】
为了对抗附近敌国的威胁,国家 R 更新了他们的导弹防御系统。新型系统可以击落一系列导弹,只要它们按高度升序或按高度降序到来。
给定一系列到来导弹的高度,将军想知道需要多少套新型系统才能将它们全部击落。
【输入格式】
输入包含多个测试用例。每个测试用例的第一行包含一个整数 。接下来的一行包含 个不同的整数,表示高度。
【输出格式】
对于每个测试用例,输出一行,包含所需系统的数量。
【样例解释】
对于样例,需要两套系统。一套击落 3、4 号导弹,另一套击落 5、2、1 号导弹。
翻译来自于:ChatGPT
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.