Wrong Answer for Subtask 1

This CodeChef: Practical coding for everyone is the my solution to the question CGSURYA Problem - CodeChef . I am getting wrong answer for subtask, while I am passing Subtask 2 and 3. Can anyone help me.

Hello,
You missed following test case:

1

3

LLL

2 5 1

Answer = -1

ACed Solution by me: https://www.codechef.com/submit/complete/20292334

My opinion: test cases were pretty weak because a wrong submission got more points than slow but correct submission

I changed my code accordingly, but still I am getting Wrong Answer in one subtask. Here is my updated code.
CodeChef: Practical coding for everyone.
Also I am not able to access your solution. The link shows access denied.