#P3929. SAC E#1 - 一道神题 Sequence1
SAC E#1 - 一道神题 Sequence1
Description
Xiaoqiang really likes sequences. One day, on a whim, he wrote down a sequence.
Amiba also likes sequences, but he only likes one kind: wave sequences.
A wave sequence of length satisfies, for any , exactly one of the following two sets of conditions (the same one):
- and (if it exists).
- and (if it exists).
Amiba told Xiaoqiang about his preference. Xiaoqiang decided to make a small change to turn the sequence into a wave sequence. He wants to know whether it is possible to make the original sequence a wave sequence by modifying at most one number (or not modifying it).
Input Format
The input contains multiple test cases.
Each test case consists of two lines:
- The first line contains an integer denoting the length of the sequence.
- The second line contains integers, representing a sequence.
Output Format
For each test case, output one line Yes or No, as described.
5
1 2 3 2 1
5
1 2 3 4 5
Yes
No
Hint
Constraints and Conventions
- For of the testdata, .
- For another of the testdata, .
- For of the testdata, , .
Here (the maximum absolute value in the sequence).
Translated by ChatGPT 5
京公网安备 11011102002149号