There are N stones lying in a line. The cost and type of the ith stone is a[i] units and i respectively. You are initially having zero stones and you wish to collect all the