I guess we can't delete the smaller value.. but while creating a priority_queue if we create using greater<int> then we can delete small value, but we can't delete higher value..
For the second question can we try somthing like this..
int i, j;
j = p.top();
so that q remains like that and p will be deleted by the end..
I am not sure how much it will work.. so thought to give my thoughts to start the discussion..
If it is not manditory to take a priority_queue we can take vector instead of that..