Bounce of a ping pong ball vs bounce of other things (How does the material affect ?)

Yesterday I saw that a ping pong ball bounced nicely on a hard surface but poorly on a mattress.On the contrary ,I saw that other things (a pen for example) bounced poorly on a hard surface but nicely on a mattress

Please I want to know the reason behind the motion and more importantly why the difference is there

EDIT:

I found that certain materials rapidly lose their Kinetic energy on striking hard surfaces but a mattress manages to store the kinetic energy of the object as elastic potential energy and returns it in accord with its elasticity.

What I find intriguing now is the properties of the material which contribute to loss of KE. Any help is highly appreciated.

NOTE: I ensured that the pen hit the surface with minimum area in contact (the side from which the nib comes out) and the nib was removed.

       The pen material didn't look like it could be easily be deformed.


$$Impact={1\over A}$$ (here $A$ is the area of the object)