Help Ramu challenge

what is the logic behind finding minimum fare?

@dsdishu99
take this Example : Suppose you are buying Maggie packet and the shopkeeper has 2 types of packets available which are as follows :- 1 kg 500 Rs and 0.5 Kg 240 Rs and your need is to buy 1 Kg Maggie so in this case obviouly you will buy 2 Half Kgs packets as it will cost 480 Rs and 1 Kg is of 500 Rs ….

Same we are going to implement in this Question.

c1 - Ticket cost for 1 ride on rickshaw or cab.
c2 - Ticket cost for unlimited rides on some rickshaw or cabs.

Now if you have 2 cabs and if you have only these 2 types of tickets available then obviously just like the above example you will first check the cost of buying Two c1 tickets and cost of 1 c2 Ticket. Among them the minimum cost willl be your answer. Now consider 1 more ticket which says c3 is the cost of ride on all rickshaws or on all cabs. then obviously now you will check the minimum cost of buying individual c1 ticket for each ride or c2 ticket for some rickshaw or on some cabs or c3 ticket for all rickshaws or all cabs.

Now assume there is 1 more ticket saying unlimited cost for ride on all rickshaws and all cabs. Here your final answer will be the minimum cost of previously calculated cost using c1, c2 and c3 tickets and cost of c4 ticket.

not passing all the test cases

@dsdishu99 Please declare these variables zero before every testcase
ansr=0;
ansc=0;
sumr=0;
sumc=0;
If you don’t have any further queries,please mark the doubt as resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

you have to do initialization inside while loop
so that this happens for each testcase