Solvable dynamics of N driven two-level atoms coupled to a dissipative cavity mode