Error in the question of fractional knapsack

this is my code error is in sort function kindly tell me how to correct it

hello @simi_1188
declare ur cmp function after the definition of structure.

while submitting it is showing runtime error
https://practice.geeksforgeeks.org/problems/fractional-knapsack/0

declare ur vector like->
vector a(n); // this will create vector of size n

also they were asking to print upto 2 decimal precision
so added cout<<fixed<<setprecision(2)<<output; // to print output upto 2 decimal

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.