문제
Bessie likes to watch shows on Mooloo. Because Bessie is a busy cow, she has planned a schedule for the next () 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 () moonies to subscribe to Mooloo for 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 and .
The second line contains integers describing the days Bessie will watch Mooloo: .
출력
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: Inputs 6-12: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인