Logo
(追記) (追記ここまで)

10137번 - Freight 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB338985925.541%

문제

The train stations in Upper Bytown and Lower Bytown are connected with a single track rail link. It takes the train s minutes to travel between them in either direction. However, the trains departing a station have to be spaced at least one minute apart. Moreover, at all times, all the trains on the rail link have to go in the same direction.

According to the timetable at our disposal, n cargo trains destined for Lower Bytown are to pass through the Upper Bytown. They are to be loaded with goods in Lower Bytown and then return to Upper Bytown. For simplicity, we assume that loading the goods on the train takes virtually no time.

We are to determine the minimum possible time of the last train returning to Upper Bytown.

입력

The first line of the standard input contains two integers n, s(1 ≤ n ≤ 1,000,000, 1 ≤ s ≤ 109), separated by a single space, that specify the number of trains and the one-way travel time respectively. The second line contains n integers t1,t2,…,tn(0 ≤ t1 ≤ t2 ≤ … ≤ tn ≤ 109), separated by a single space, that specify the arrival times of successive trains at the Upper Bytown station.

In test worth 50% of the total score, n ≤ 5000 holds. Moreover, in their subset worth 25% of the total score, n ≤ 400 holds in addition.

출력

Your program should print out a single line with a single integer to the standard output: the minimum possible time of the last train returning to Upper Bytown.

제한

예제 입력 1

3 4
1 8 11

예제 출력 1

20

힌트

To attain the minimum time, the trains can depart from Upper Bytown at times 1, 9, and 11, and from Lower Bytown at times 5, 15, and 16.

출처

Olympiad > Polish Olympiad in Informatics > POI 2013/2014 > Stage 3 6번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /