Double-spin asymmetries for production of charged pions and kaons in semi-inclusive deep-inelastic muon scattering have been measured by the COMPASS experiment at CERN. The data, obtained by scattering a 160 GeV muon beam off a longitudinally polarised NH_3 target, cover a range of the Bjorken variable x between 0.004 and 0.7. A leading order evaluation of the helicity distributions for the three lightest quarks and antiquark flavours derived from these asymmetries and from our previous deuteron data is presented. The resulting values of the sea quark distributions are small and do not show any sizable dependence on x in the range of the measurements. No significant difference is observed between the strange and antistrange helicity distributions, both compatible with zero. The integrated value of the flavour asymmetry of the helicity distribution of the light-quark sea, \Delta u-bar - \Delta d-bar, is found to be slightly positive, about 1.5 standard deviations away from zero.