Stores pairs { priority , quantity } of each sweet - type
ArrayList < Pair < Integer , Pair < Integer , Integer > > > v = new ArrayList < > ( ) ; for ( int i = 0 ; i < n ; i ++ ) v . add ( Pair . of ( b [ i ] , Pair . of ( a [ i ] , i + 1 ) ) ) ;