Bethe ansatz derivation of the Tracy-Widom distribution for one-dimensional directed polymers