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

22283번 - Driving Lanes 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB32231990.476%

문제

While driving around a curve on the highway, Sam realizes that if they use the inside lane, they travel a shorter distance. Sam wonders what is the minimum distance needed to travel to the destination.

The multilane highway consists of a sequence of straightaways that are connected by curves. When going around a curve, the distance travelled depends on which lane you are in. Each curve has a curvature $c$ and stretch $s$. Specifically, if Sam is in lane $i,ドル then they travel $s + c \cdot i$ meters while going around this curve.

Whenever Sam is on a straightaway, they may change from one lane into an adjacent lane. When changing to an adjacent lane, Sam moves forward $k$ meters, but travels a total of $k+r$ meters. Each lane change must be completed before the car reaches the end of the current straightaway. Sam may change lanes multiple times in the same straightaway. For safety reasons, changing lanes is not possible on curves.

Sam starts in lane 1ドル$ and wishes to end in lane 1ドル$. What is the minimum distance they must travel?

입력

The first line of input contains two integers $n$ (1ドル \leq n \leq 250$), which is the number of straightaways, and $m$ (1ドル \leq m \leq 250$), which is the number of lanes on the highway. The lanes are numbered 1,ドル 2, \dots, m$.

The second line of input contains two integers $k$ (1ドル \leq k \leq 10^6$) and $r$ (1ドル \leq r \leq 10^6$), which are the lane changing parameters.

The next $n$ lines describe the straightaways in order. Each of these lines contains a single integer $\ell$ (1ドル \leq \ell \leq 10^6$), which is the length of this straightaway.

The next $n-1$ lines describe the curves in order. Each of these lines contains two integers $s$ (1ドル \leq s \leq 10^6$), which is the stretch of this curve, and $c$ ($-10^6 \leq c \leq 10^6$), which is the curvature of this curve. It is guaranteed that $s + c \cdot m > 0$.

The $i$th curve connects the $i$th and $(i+1)$th straightaway.

출력

Display the minimum distance Sam must travel.

제한

예제 입력 1

4 3
5 2
10
10
10
10
4 -1
4 -1
4 1

예제 출력 1

51

예제 입력 2

4 3
5 2
10
10
10
10
10 -3
10 -3
10 1

예제 출력 2

61

힌트

출처

ICPC > Regionals > North America > Rocky Mountain Regional > 2018 Rocky Mountain Regional Contest E번

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

출처

대학교 대회

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

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