Getting wrong output ,Please modify my code
Deepak and his journey
@dsingh200021 hey Darsh preet
I am suggesting you a simple approach
1 take input n
2 make three vectors C(n),L(n),M(i)
the return type of vectors is long long
3 apply a loop from i=0 to n-1
take input for the first vectors
i.e cin>>C[i];
4 In this loop a conditional statement required
if(i==0)
M[i]=C[i];
else
M[i]=min(M[i-1],C[i]);
end of loop
5 apply a loop from i=0 to n-1
take input for the third vector L[i];
end of loop
6 take two variable
petrol_available=0
final_cost=0
7 Again apply a loop from i=0 to n-1
final_cost+=L[i]*M[i];
end of loop
8 print final_cost
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.