#627
Silver IV
Watching Mooloo
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Bessie likes to watch shows on Mooloo. Because Bessie is a busy cow, she has planned a schedule for the next NN (1N1051 \leq N \leq 10^5) days that she will watch Mooloo. Because Mooloo is a paid subscription service, she now needs to decide how to minimize the amount of money she needs to pay.

Mooloo has an interesting subscription system: it costs d+Kd + K (1K1091\le K\le 10^9) moonies to subscribe to Mooloo for dd consecutive days. You can start a subscription at any time, and you can start a new subscription as many times as you desire if your current subscription expires. Given this, figure out the minimum amount of moonies Bessie needs to pay to fulfill her schedule.

입력

The first line contains integers NN and KK.

The second line contains NN integers describing the days Bessie will watch Mooloo: 1d1<d2<<dN10141\le d_1<d_2<\dots<d_N\le 10^{14}.

출력

Note that the large size of integers involved in this problem may require the use of 64-bit integer data types (e.g., a "long long" in C/C++).

예제 입력 1

2 4
7 9

예제 출력 1

7

예제 입력 2

2 3
1 10

예제 출력 2

8

점수

Inputs 3-5: N10N \le 10 Inputs 6-12: No additional constraints.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Silver IV1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.