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

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

Platform Placing

시간 제한1.5초메모리 제한1024 MB

요약
직선 위의 점 각각을 중심으로 길이가 [s,k]인 구간을 겹치지 않게 배치해 전체 길이의 합을 최대로 만들고, 불가능하면 -1을 출력한다.
난이도

보통10점 중 7점

유형
동적 계획법, 이분 탐색, 그리디
정답자
아직 제출이 없습니다

문제

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 ℓ\ell anchored to a foundation point at position xx along the line occupies the interval \[x−ℓ2,x+ℓ2]\[x - \frac{\ell}{2}, x + \frac{\ell}{2}] 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 nn (1≤n≤1051 \le n \le 10^5), ss and kk (1≤s≤k≤1051 \le s \le k \le 10^5), where nn is the number of foundation points, ss is the smallest platform length possible, and kk is the largest platform length possible.

Each of the next nn lines contains a single integer xx (1≤x≤1091 \le x \le 10^9), 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 −1-1 if it isn't possible to place the platforms.

예제3

  1. 예제 1

    입력
    4 1 4
    1
    6
    8
    10
    
    예상 출력
    11
    
  2. 예제 2

    입력
    5 1 6
    6
    7
    8
    3
    5
    
    예상 출력
    7
    
  3. 예제 3

    입력
    2 5 10
    1
    2
    
    예상 출력
    -1