We perform density functional theory calculations to investigate the partitioning behavior of Ti and V between cementite and ferrite. The energetics show that Ti and V partition to cementite. The chemical bonds in Ti- and V-substituted cementite are stronger than that of cementite, and these alloyed cementite are more stable than cementite. Furthermore, the elastic properties of alloyed cementite are investigated. Ferromagnetic Ti- and V-substituted cementite are mechanically stable, but non-magnetic Ti- and V-substituted cementite are mechanically unstable. Ti and V partitioning can enhance the resistance to shear strain, the stiffness and the stability against shear of ferromagnetic cementite. Finally, we present the electronic structures to understand the bonding properties of the alloyed cementite.