Gain mechanism in time-dependent media