Add coins at even indices to the amount collected by A
sort ( mid_odd . begin ( ) , mid_odd . end ( ) ) ; for ( int i = 0 ; i < mid_odd . size ( ) ; i ++ ) if ( i % 2 == 0 ) amount = amount + mid_odd [ i ] ;