The set union problem with dynamic weighted backtracking