Check if current shop can be assigned to a person who 's  already visiting any other shop
bool flag = false ; if ( ! st . empty ( ) ) { auto it = st . upper_bound ( a [ i ] . first ) ; if ( it != st . begin ( ) ) { it -- ;