The propagation of optical beams in weakly nonlocal media with cubic-quintic nonlinearity is studied. The exact solutions for bright and dark solitons are found. The general solutions are implicit, and they are expressed in terms of the elliptic integrals. In particular cases, the solutions are written explicitly in terms of the hyperbolic functions. The dependence of the beam parameters and the soliton shapes on the system parameters is analyzed. The role of nonlocality on the soliton stability is investigated.