Help ramu solution

I am getting the same output with this code but after its submission it is showing incorrect testcases why?
also i have to use two times the same loop(line 13 and 20) for finding the sum and if i m doing that in one then i m not getting correct output why?

plz resolve it

@aditi2512201012019
hello aditi,
I m checking ur code till then pls check this video-> https://codingblocks.com/resources/help-ramu-in-minimum-cost/

i had already checked my code with this.

@aditi2512201012019
hello aditi,
check ur line no 25,it should be c[j] but u have written c[i] .rest evrthing is correct

and what about using the loop 2 times i.e line 13 and 20

@aditi2512201012019
yeah u can combine loop in line no 13 with loop in line no 20. similarly loop in line no 16 with loop in lin no 24.