Sereja and two strings

qstn http://www.codechef.com/OCT14/problems/SEATSR

soltn :http://ideone.com/LOcv6I

My solution is defiantly wrong as it doesn’t passes the given test cases also(thus my approach too)can anyone please suggest where i had approached wrong

i am trying to solve the problem through memorization

description

add1,del1,rem1 are three variable which calculate how much time*weight-age(cost of add,rem) add,del,remove oprtn is performed on string

example if cost of remove is 2 and it is performed 3 times then rem1=2*3 similarly for add1,del1

if cost of add1+del1+rem1>k return infinity as it crosses the limit

i think now code is understood able if not please ask me i will explain