To test the predictive power of ab initio nuclear structure theory, the lifetime of the second 2+ state in neutron-rich 20O, tau(2+_2 ) = 150(+80-30) fs, and an estimate for the lifetime of the second 2+ state in 16C have been obtained, for the first time. The results were achieved via a novel Monte Carlo technique that allowed us to measure nuclear state lifetimes in the tens-to-hundreds femtoseconds range, by analyzing the Doppler-shifted gamma-transition line shapes of products of low-energy transfer and deep-inelastic processes in the reaction 18O (7.0 MeV/u) + 181Ta. The requested sensitivity could only be reached owing to the excellent performances of the AGATA gamma-tracking array, coupled to the PARIS scintillator array and to the VAMOS++ magnetic spectrometer. The experimental lifetimes agree with predictions of ab initio calculations using two- and three-nucleon interactions, obtained with the valence-space in-medium similarity renormalization group for 20O, and with the no-core shell model for 16C. The present measurement shows the power of electromagnetic observables, determined with high-precision gamma spectroscopy, to assess the quality of first-principles nuclear structure calculations, complementing common benchmarks based on nuclear energies. The proposed experimental approach will be essential for short lifetimes measurements in unexplored regions of the nuclear chart, including r-process nuclei, when intense ISOL-type beams become available.