All submissions for this problem are available.
Varun is the President of Society of Robotics, Delhi Technological University, and Surbhi is the Treasurer. One day Varun brings his younger brother with him to college. Varun had some work with Surbhi regarding the payments and sponsors for the technical fest, Excelsior. He went to her room to see her, but she was not there. There was a sequence of N cards lying on the table, each with a number written on it. While he went looking for her, he left his brother in there. Being a naughty child, he started playing with the cards. He added some new cards from a box nearby, removed some, and shuffled some. When Varun returned, he noticed what his brother had done. He has to restore the original sequence, before Surbhi returns.
He can do the following operations-
- He can add a card with any number on it, at any position. This takes t1 seconds.
- He can remove a card from any position, this takes t2 seconds.
- He can erase the number on a card and write any other number. This takes t3 seconds.
- He can swap any two adjacent cards. This takes t4 seconds.
Find the minimum time it’ll take him to replace the original sequence.
- First line contains T, the number of test cases.
- The first line of each test case, contains two space separated integers, N and M. M is the number of cards left on the table after the brother’s mischief.
- Next line contains N space separated integers, the original sequence, A1 A2 A3… AN
- Next line contains M space separated integers, the new sequence after the brother’s meddling, B1 B2 B3… BM
- Next line contains 4 space separated integers, t1 t2 t3 t4
Print a single line for each test case containing minimum time taken by Varun to do the task.
- 1 <= N <= 100
- 1 <= M <= 100
- 1 <= T <= 100
- 2*t4 >= t1+t2
- 1 <= Ai <= 100
- 1 <= Bi <= 100
Input: 4 3 4 15 64 98 15 64 98 100 1 2 1 4 5 5 1 2 3 4 5 1 2 3 5 4 1 1 1 1 4 7 2 4 8 6 8 6 4 3 5 2 4 1 1 1 1 5 5 1 2 3 4 5 2 1 4 3 6 1 1 1 1 Output: 2 1 6 3
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.