Check if the current buying price is greater than that of the previous transaction
while ( ! transaction . empty ( ) && prices [ buy ] < prices [ transaction . top ( ) . first ] ) { pair < int , int > p = transaction . top ( ) ;