Tavis-Cummings (TC) cavity quantum electrodynamical effects, describing the interaction of N atoms with an optical resonator, are at the core of atomic, optical and solid state physics. The full numerical simulation of TC dynamics scales exponentially with the number of atoms. By restricting the open quantum system to a single excitation, typical of experimental realizations in quantum optics, we analytically solve the TC model with an arbitrary number of atoms with linear complexity. This solution allows us to devise the Quantum Mapping Algorithm of Resonator Interaction with N Atoms (Q-MARINA), an intuitive TC mapping to a quantum circuit with linear space and time scaling, whose N+1 qubits represent atoms and a lossy cavity, while the dynamics is encoded through 2N entangling gates. Finally, we benchmark the robustness of the algorithm on a quantum simulator and superconducting quantum processors against the quantum master equation solution on a classical computer.