Heavy element nucleosynthesis associated with a gamma-ray burst