Section 77. After the completion of the work, the expense of maintenance and repair shall be paid as follows: if the public way crosses the railroad by an overhead bridge, the superstructure and subflooring of the bridge and its abutments or other supports shall be maintained and kept in repair by the railroad corporation, but the approaches of the bridge and the pavement or wearing surface over the subflooring shall be maintained and kept in repair by the city or town where situated, or, in case such public way is a state highway, by the commonwealth; if the public way passes under the railroad, the bridge and its abutments or supports shall be maintained and kept in repair by the railroad corporation, and the public way and its approaches shall be maintained and kept in repair by the city or town where situated, or, in case such public way is a state highway, by the commonwealth; if several railroads cross a public way at or near a given point, the department of highways shall apportion and award in what manner and proportion each of said railroad corporations shall maintain and keep in repair the superstructure and subflooring of the bridge and its abutments or supports if the public way crosses the railroad by an overhead bridge, and the bridge and its abutments or supports if the public way passes under said railroads.