We performed a quantitative study of the nuclei with proton numbers from Z=20 (Ca) to Z=28 (Ni) and neutron numbers ranging from N=38 to 52 using the realistic shell model, which merged the descriptions of nuclei around N=40 and N=50 within an extended model space. The 21+ excitation energy (E(21+)) is calculated for neutron-rich Cr, Fe, and Ni isotopes. The results suggest that the islands of inversion at N=40 and N=50 merge around the Cr chain, and the N=50island of inversion is located below 78Ni. To demonstrate the prediction of the N=50island of inversion, we calculated and compared the E(21+), B(E2;01+→21+), effective single-particle energies (ESPEs), the probability of particle-hole excitation, and the average occupations in the N=40 and N=50 isotones. Similar parabolic trends of E(21+) and B(E2;01+→21+) in the N=40 and 50 isotones are obtained. The calculated ESPEs give that the N=40 and N=50 shell gaps both increase with the variation of proton number from Z=20 (Ca) to Z=28 (Ni). However, our calculations indicate that different particle-hole excitations dominate in the ground states of the N=40 and N=50islands of inversion, with 2p2h and 4p4h configurations being prominent in N=40 isotones, whereas 2p2h excitations are most important in the N=50 isotones. Furthermore, large occupations of the intruder quadrupole partner orbitals are also obtained in N=40 and N=50 isotones in our realistic shell model calculations.