Aims. To investigate the role of acoustic and magneto-acoustic waves in heating the solar chromosphere, observations in strong chromospheric lines are analyzed by comparing the deposited acoustic-energy flux with the total integrated radiative losses. Methods. Quiet-Sun and weak-plage regions were observed in the Ca II 854.2 nm and H-alpha lines with the Fast Imaging Solar Spectrograph (FISS) at the 1.6-m Goode Solar Telescope (GST) on 2019 October 3 and in the H-alpha and H-beta lines with the echelle spectrograph attached to the Vacuum Tower Telescope (VTT) on 2018 December 11 and 2019 June 6. The deposited acoustic energy flux at frequencies up to 20 mHz was derived from Doppler velocities observed in line centers and wings. Radiative losses were computed by means of a set of scaled non-LTE 1D hydrostatic semi-empirical models obtained by fitting synthetic to observed line profiles. Results. In the middle chromosphere (h = 1000-1400 km), the radiative losses can be fully balanced by the deposited acoustic energy flux in a quiet-Sun region. In the upper chromosphere (h > 1400 km), the deposited acoustic flux is small compared to the radiative losses in quiet as well as in plage regions. The crucial parameter determining the amount of deposited acoustic flux is the gas density at a given height. Conclusions. The acoustic energy flux is efficiently deposited in the middle chromosphere, where the density of gas is sufficiently high. About 90% of the available acoustic energy flux in the quiet-Sun region is deposited in these layers, and thus it is a major contributor to the radiative losses of the middle chromosphere. In the upper chromosphere, the deposited acoustic flux is too low, so that other heating mechanisms have to act to balance the radiative cooling.