아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Mountains

면접 대비

시간 제한1초메모리 제한512 MB

요약
n개 꼭짓점으로 이루어진 산맥이 주어질 때, 집합 안 어떤 두 꼭짓점을 이어도 그 사이에 두 점을 잇는 선분보다 높은 꼭짓점이 존재하도록 하는 가장 큰 꼭짓점 집합의 크기를 구한다.
난이도

보통10점 중 7점

유형
동적 계획법, 기하, 배열, 완전 탐색
정답자
아직 제출이 없습니다

문제

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 nn vertices. The ii-th vertex (for all 0≤i≤n−10 \le i \le n - 1) has coordinates (i,y\[i])(i, y\[i]), i.e. with longitude ii and altitude y\[i]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 00 can see deevs on vertices 11 and 22. But it cannot see deevs on vertices 33, 44 and 55, since vertex 22 is higher than the line connecting vertex 00 to any of vertices 33, 44, or 55.

Your task is to help Tahmuras find the maximum number of deevs that can be imprisoned in Alborz mountains.

제한

  • 1≤n≤20001 \leq n \leq 2000,
  • 0≤y\[i]≤1090 \leq y\[i] \leq 10^9 (for all 0≤i<n0 \leq i < n).

예제

이 문제는 공개된 예제가 없습니다.