Ezra Stiles was a Congregationalist minister in Newport, Rhode Island in the late 18th century. He was a frequent visitor to the Newport Synagogue and there met Rabbi Raphael Hayyim Issac Carregal, a meshulach [fund raiser] from Hebron. In his diary, Stiles relates a question he asked Rabbi Carregal that stumped the good rabbi. After the rabbi agreed that marriage partners would be reunited in the resurrection, Stiles asked whether a woman was married to more than one man, to whom would she be reunited in the Resurrection? Rabbi Carregal (whose name is misspelled at that point in the diary, but spelled correctly elsewhere) replied that there are several opinions, but he did not know the answer. What opinions was he referring to?
Rav Pe'alim 2 - Sod Yesharim 2 says that she will return to her first husband since before Techiyas Hameisim the Neshama returns to the Neshama of the first spouse therefore it will remain so after Techiyas Hameisim. He further says that the (Guf) body that will get up for Techiyas Hameisim is a new Guf and the previous connection with the second husband will be broken.
Sefer Anaf Yosef - Sanhedrin beginning Perek Chelek says that the death of the first husband is similar to a divorce and the wife will remain with the second husband after Techiyas Hameisim.