CF67C.Sequence of Balls

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given a sequence of balls AA by your teacher, each labeled with a lowercase Latin letter 'a'-'z'. You don't like the given sequence. You want to change it into a new sequence, BB that suits you better. So, you allow yourself four operations:

  • You can insert any ball with any label into the sequence at any position.
  • You can delete (remove) any ball from any position.
  • You can replace any ball with any other ball.
  • You can exchange (swap) two adjacent balls.

Your teacher now places time constraints on each operation, meaning that an operation can only be performed in certain time. So, the first operation takes time tit_{i} , the second one takes tdt_{d} , the third one takes trt_{r} and the fourth one takes tet_{e} . Also, it is given that 2te>=ti+td2·t_{e}>=t_{i}+t_{d} .

Find the minimal time to convert the sequence AA to the sequence BB .

输入格式

The first line contains four space-separated integers ti,td,tr,tet_{i},t_{d},t_{r},t_{e} ( 0<ti,td,tr,te<=1000<t_{i},t_{d},t_{r},t_{e}<=100 ). The following two lines contain sequences AA and BB on separate lines. The length of each line is between 1 and 4000 characters inclusive.

输出格式

Print a single integer representing minimum time to convert AA into BB .

输入输出样例

  • 输入#1

    1 1 1 1
    youshouldnot
    thoushaltnot
    

    输出#1

    5
    
  • 输入#2

    2 4 10 3
    ab
    ba
    

    输出#2

    3
    
  • 输入#3

    1 10 20 30
    a
    za
    

    输出#3

    1
    

说明/提示

In the second sample, you could delete the ball labeled 'a' from the first position and then insert another 'a' at the new second position with total time 6. However exchanging the balls give total time 3.

首页