X. Missile Defence System

    远端评测题 2000ms 512MiB

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(1n50)n (1 \le n \le 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.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.

搜索【B】

未认领
状态
已结束
题目
54
开始时间
2025-11-14 0:00
截止时间
2026-2-6 23:59
可延期
24 小时