#P7401. [COCI 2020/2021 #5] Planine
[COCI 2020/2021 #5] Planine
Description
There is a mountain with ups and downs. It can be modeled as a polygon consisting of points (where is odd), plus the two points and .
For every integer satisfying , , and , the point is a valley.
Now we want to place some point light sources at height , so that all valleys are illuminated, meaning the line segment connecting a light source and a valley does not pass through the interior of the mountain.
Find the minimum number of light sources needed.
Input Format
The first line contains integers .
The next lines each contain integers .
It is guaranteed that and $y_1 < y_2, y_2 > y_3, y_3 < y_4, \cdots, y_{n-1} > y_n$.</p>
Output Format
Output the minimum number of light sources needed.
9 6
0 0
1 2
3 0
6 3
8 1
9 2
11 1
12 4
14 0
1
9 5
-5 2
-4 3
-2 1
0 4
2 2
3 3
4 1
5 2
6 1
2
Hint
Illustration for Sample 1

Illustration for Sample 2

Constraints
This problem uses bundled testdata.
| Subtask | Score | Constraints and Notes |
|---|---|---|
| None |
For of the testdata: , , , , , , and $y_1 < y_2, y_2 > y_3, y_3 < y_4, \cdots, y_{n-1} > y_n$.</p>
Notes
The scoring of this problem follows the original COCI problem, with a full score of .
Translated from COCI2020-2021 CONTEST #5 T4 Planine.
Translated by ChatGPT 5
>>>>
京公网安备 11011102002149号