Map to store the indices in A and B which produce the given difference
std :: map < int , pair < int , int > > index ; int difference ; index [ 0 ] = make_pair ( -1 , -1 ) ; int j = 0 ; for ( int i = 0 ; i < N ; ++ i ) {