Method of conditional minimization for the numerical solution of a nonstationary problem with free boundaries