Uniqueness results for optimization problems with prescribed rearrangement