Platform Placing
시간 제한1.5초메모리 제한1024 MB
직선 위의 점 각각을 중심으로 길이가 [s,k]인 구간을 겹치지 않게 배치해 전체 길이의 합을 최대로 만들고, 불가능하면 -1을 출력한다.
문제
The city of Atlantis is making an above-water section. They are doing so by building floating platforms that are anchored at their centers to foundation points that lie in a straight line at the bottom of the ocean. Each platform is a fixed-width rectangle aligned to the foundation line; specifically, a platform of length anchored to a foundation point at position along the line occupies the interval along the line on the ocean surface. The platforms can be of different lengths, but have both a minimum and a maximum length. Gaps are allowed between consecutive platforms, and platforms are allowed to exactly touch, but they may not overlap. Each foundation point must be attached to exactly one platform.
Help the Atlanteans maximize their above-water section: given the locations of the foundation points and the minimum and maximum allowed platform lengths, determine the maximum possible sum of platform lengths.
입력
The first line of input contains three space separated integers (), and (), where is the number of foundation points, is the smallest platform length possible, and is the largest platform length possible.
Each of the next lines contains a single integer (), representing the location of a foundation point. No two foundation points will be the same.
출력
Output a single integer, which is the maximum possible sum of platform lengths, or if it isn't possible to place the platforms.