Whenever federal-aid highway funds are available and are used to pay a portion of the cost of installing a grade crossing protective device, and related work, at a railroad crossing of any state highway, city or town street, or county road at the then prevailing federal-aid matching rate, the grade crossing protective fund shall pay ten percent of the remaining cost of such installation and related work. The state or local authority having jurisdiction of such highway, street, or road shall pay the balance of the remaining cost of such installation and related work. The railroad whose road is crossed by the highway, street, or road shall thereafter pay the entire cost of maintaining the device.