autoput | 프로그래밍의 벗 PivotOJ
PivotOJ

autoput

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2005 National Competition #1 - JuniorsBOJ 3191
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

Imagine one simple road in a coordinate system. Road is going from left to right, following the configuration of the land and within one square it can: 

  1. stay on the same height 
  2. go down or up by one square 

Car is driving on the road from left to right. The time needed to travel through a single square is either A seconds for the case a), or B seconds for the case b). 

However, we can build a tunnel under some mountain or a viaduct above some valley. These objects have to be horizontal, and the time needed for a car to travel through a single square on a tunnel or viaduct is C seconds. 

Write a program that will, for a given configuration of land, calculate the minimal time for a car to travel the whole road with optimal construction of tunnels and viaducts. Total number of objects built must not be greater than the given number K. 

[이미지 1]

Figure above corresponds to the third example. Original road is denoted by the thin line, and the optimal path is denoted by the thick line. Because the number of objects is restricted to 2, we could not build a tunnel under the first mountain. 

입력

First line of input contains three integers A, B and C, 1 ≤ A,B,C ≤ 100. 

Second line of input contains two integers N and K, 1 ≤ N ≤ 30,000, 1 ≤ K ≤ 1,000. 

Third line of input contains a sequence of N characters that describes the configuration of the land, from left to right. Each character in the sequence is one of the following: 

  • 'D' in next square land is going DOWN 
  • 'R' in next square land is staying on the SAME HEIGHT 
  • 'G' in next square land is going UP 

출력

First and only line of output should contain the minimal time from the problem statement. 

예제

예제 1

입력
3 2 1
9 1
GGDGGDDRR
출력
16

예제 2

입력
3 5 4
10 10
RGDRDRRRRG
출력
36

예제 3

입력
10 20 15
16 2
RGRDGGDDRRDDRDGG
출력
235
코드를 제출하려면 로그인하세요.