#TEST1016. 逃离火场(easy version)
逃离火场(easy version)
Description
This is the easier version of this question. The only difference between the two versions is that this one has a smaller range of data.
Jiang Xinting is studying teleportation at QiLing University ( ). The QiLing University's sacred animal, the Fire QiLing, will stimulate her studies with its powerful fire magic.
There are buildings in QiLing University, numbered , and the height of the building is . The first buildings will be set on fire, which means that only the building is safe. Jiang Xinting starts in the building, and she needs to teleport to the building.
Since Jiang Xinting's teleportation magic is very slow, she can only jump from () to () if at least one of the following conditions is met.
- $\max(h_{i + 1}, \ldots, h_{j - 1}) < \min(h_i, h_j)$
- $\max(h_i, h_j) < \min(h_{i + 1}, \ldots, h_{j - 1})$.
Jiang Xinting can't teleport too many times due to her lack of stamina from staying up late all night. She wants you to help her calculate the minimum number of teleports needed to reach the th building.
Input
The first line is two integers .
The second integer, (), represents the height of each building.
Output
Output line with an integer indicating the minimum number of transmissions to reach the th building.
Samples
5
1 3 1 4 5
``Output1 3
```Input2
4
4 2 2 4
1
Hints
In sample , Jiang Xinting can be transmitted by the following path: .
Related
In following contests: