Whenever two or more lines of railroad owned or operated by different companies cross a highway, or each other, by an over-crossing, under-crossing, or grade crossing required or permitted by this chapter or by an order of the commission, the portion of the expense of making such crossing not chargeable to any municipality, county, or to the state, and the expense of constructing and maintaining such signals, warnings, flaggers, interlocking devices, or other devices or means to secure the safety of the public and the employees of the railroad company, as the commission may require to be constructed and maintained, shall be apportioned between said railroad companies by the commission in such manner as justice may require, regard being had for all facts relating to the establishment, reason for, and construction of said improvement, unless said companies shall mutually agree upon an apportionment. If it becomes necessary for the commission to make an apportionment between the railroad companies, a hearing for that purpose shall be held, at least ten days' notice of which shall be given.