We simulate time-dependent particle acceleration in the blast wave of a young supernova remnant (SNR), using a Monte Carlo approach for the diffusion and acceleration of the particles, coupled to an MHD code. We calculate the distribution function of the cosmic rays concurrently with the hydrodynamic evolution of the SNR, and compare the results with those obtained using simple steady-state models. The surrounding medium into which the supernova remnant evolves turns out to be of great influence on the maximum energy to which particles are accelerated. In particular, a shock going through a $rho propto r^{-2}$ density profile causes acceleration to typically much higher energies than a shock going through a medium with a homogeneous density profile. We find systematic differences between steady-state analytical models and our time-dependent calculation in terms of spectral slope, maximum energy, and the shape of the cut-off of the particle spectrum at the highest energies. We also find that, provided that the magnetic field at the reverse shock is sufficiently strong to confine particles, cosmic rays can be easily re-accelerated at the reverse shock.