Planine
의견: 0
Zoran wanders across his Dalmatian homeland to forget his love woes. He came across a mountain of a
specific shape, behind which a young maiden is waiting for him. The mountain can be described with
\(n\) alternating low and high points, where \(n\) is odd. Points at odd indices, except the first and the last
point, are called valleys.
Zoran is afraid of the dark. Even the call of love will not give him courage to cross the mountain at night.
As usual, the fairies of Velebit come to the rescue.
We model each fairy by a luminous dot at a fixed height \(h\). A fairy illuminates the valley if and only if
the segment connecting the fairy and the valley does not intersect the interior of the mountain.
The mountain from the first example, and a fairy illuminating all three valleys.
What is the least number of fairies which can illuminate all the valleys simulaneously?
Subtask 1 (20 points): \(y@@RISE_MATH_BLOCK_0@@n - 1\)
Subtask 2 (30 points): \(3 \le n < 2000\)
Subtask 3 (60 points): No additional constraints.
The first line contains two integers \(n\) (\(3 \le n < 10^{6}\), \(n\) odd) and \(h\) (\(1 \le h \le 10^{6}\)), the number of points
describing the mountain and the height the fairies live at.
The \(i-th\) of the following \(n\) lines contains integers \(x@@RISE_MATH_BLOCK_0@@i\) (−\(10^{6} \le x@@RISE_MATH_BLOCK_1@@i < h\)), the coordinates
of the \(i-th\) point of the mountain.
It is guaranteed that \(x@@RISE_MATH_BLOCK_2@@1 < y\)2, \(y@@RISE_MATH_BLOCK_3@@3 < y\)4, . . ., \(y@@RISE_MATH_BLOCK_4@@n\).
Output the least number of fairies such that all valleys are illuminated.
| 서브태스크 | 점수 | 설명 |
|---|---|---|
1 | 20점 | \(y@@RISE_MATH_BLOCK_0@@n - 1\) |
2 | 30점 | \(3 \le n < 2000\) |
3 | 60점 | No additional constraints. |
9 6
0 0
1 2
3 0
6 3
8 1
9 2
11 1
12 4
14 019 5
-5 2
-4 3
-2 1
0 4
2 2
3 3
4 1
5 2
6 12Clarification of the examples:
The first example is shown in the statement.
It can be shown that the valleys in the second example cannot be illuminated using only one fairy. An
example with two fairies is given on the figure below.
평가 및 의견
Planine
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Planine