We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Really nice problem! However, I rerun the test that failed with TLE, and it passed... Strange :(
Hint alert: the price is a sum of all subprices for every component, such that the price of the component is the min((number of nodes in component) * (library price), ((number of nodes in component minus one - spanning tree edges)* (road price) + (library price))
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Roads and Libraries
You are viewing a single comment's thread. Return to all comments →
Really nice problem! However, I rerun the test that failed with TLE, and it passed... Strange :(
Hint alert: the price is a sum of all subprices for every component, such that the price of the component is the min((number of nodes in component) * (library price), ((number of nodes in component minus one - spanning tree edges)* (road price) + (library price))