Finally store the profits of all the transactions
while ( ! transaction . empty ( ) ) { profits . push ( prices [ transaction . top ( ) . second - 1 ] - prices [ transaction . top ( ) . first ] ) ; transaction . pop ( ) ; }