#P15705. [2018 KAIST RUN Spring] Zigzag
[2018 KAIST RUN Spring] Zigzag
题目描述
A sequence is called “Zigzag” if no three of its consecutive elements are monotone.
More formally, if sequence of length is Zigzag if, for all (), neither nor holds.
For given sequence of length , you should find a longest subsegment of which is a Zigzag sequence. Sequence of length is subsegment of sequence of length if, for some , , , holds.
输入格式
Input consists of two lines.
The first line contains integer , length of sequence .
The second line contains space-separated integers. th number is .
输出格式
Print out the length of longest subsegment of which is a Zigzag sequence.
3
1 2 3
2
5
1 3 4 2 5
4
提示
Constraints
- ()