Wrong answer coming

please tell the problem in the code

Hey Akshita, use long long int to avoid overflow!
rest code is fine.
FollowUP (can you solve this in O(n) complexity instead of O(NlogN)?)

is the complexity O(nlogn) beacuse of priority queue? i can use an integer in it’s place to store the minimum value

another thing, after declaring cost as long long int it still gave wrong answer. the arrays storing cost and petrol also had to be made long long int, what is the reason?

exactly! so no need to maintain a priority queue.

This is because when you multiply pq.top() and l[i], the result which is in integer already overflows! hence both of them must be long long as well.

okay thank you .