https://ide.codingblocks.com/s/249984 my code is giving right output for the sample input and wrong answers for all the test cases. what’s the mistake
Deepak and his journey(greedy)
@pooja_narula x*vcost[i] may exceed int limit before adding it to the ans so use typecasting there, calculate your answer as this
ans+=(long long)x*vcost[i];
Yes it’s working now, thanks!
1 Like
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.