| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 512 MB | 73 | 22 | 21 | 42.857% |
Tahmuras, the third king of ancient Persia, has conquered a huge army of deevs (demons). He wants to imprison as many of them as possible in Alborz mountains and let the others go. Alborz is a mountain range with a skyline that looks like a polygonal chain with $n$ vertices. The $i$-th vertex (for all 0ドル \le i \le n - 1$) has coordinates $(i, y[i]),ドル i.e. with longitude $i$ and altitude $y[i]$.
The deevs can be imprisoned on different vertices. No two imprisoned deevs should be able to see each other; otherwise, they will make eye contact and plan to escape. Two deevs cannot see each other if there is at least one vertex between them that is strictly higher than a line connecting their vertices.
In the following figure, a deev on vertex 0ドル$ can see deevs on vertices 1ドル$ and 2ドル$. But it cannot see deevs on vertices 3ドル,ドル 4ドル$ and 5ドル,ドル since vertex 2ドル$ is higher than the line connecting vertex 0ドル$ to any of vertices 3ドル,ドル 4ドル,ドル or 5ドル$.
Your task is to help Tahmuras find the maximum number of deevs that can be imprisoned in Alborz mountains.
You should implement the following procedure. It will be called by the grader once for each test case.
int maximum_deevs(int[] y)
Consider the polygonal chain given in the above figure.
maximum_deevs([6, 1, 5, 2, 3, 1])
The answer is 3ドル$. One possible solution is to imprison deevs on vertices 1ドル,ドル 3ドル$ and 5ドル$.
maximum_deevs([0, 1, 2])
The answer is 1ドル$. The deevs imprisoned on any pair of vertices can see each other (vertex 1ドル$ is on the line connecting vertices 0ドル$ and 2ドル,ドル not strictly higher).
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 20 | $n \leq 19$ |
| 2 | 20 | $n \leq 40$ |
| 3 | 30 | $n \leq 300$ |
| 4 | 30 | No additional constraints |
The sample grader reads the input in the following format:
The sample grader prints a single line containing the return value of maximum_deevs.
C++17, C++14, C++20, C++14 (Clang), C++17 (Clang), C++20 (Clang)