CF835F.Roads in the Kingdom

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In the Kingdom K., there are nn towns numbered with integers from 11 to nn . The towns are connected by nn bi-directional roads numbered with integers from 11 to nn . The ii -th road connects the towns uiu_{i} and viv_{i} and its length is lil_{i} . There is no more than one road between two towns. Also, there are no roads that connect the towns with itself.

Let's call the inconvenience of the roads the maximum of the shortest distances between all pairs of towns.

Because of lack of money, it was decided to close down one of the roads so that after its removal it is still possible to reach any town from any other. You have to find the minimum possible inconvenience of the roads after closing down one of the roads.

输入格式

The first line contains the integer nn ( 3<=n<=21053<=n<=2·10^{5} ) — the number of towns and roads.

The next nn lines contain the roads description. The ii -th from these lines contains three integers uiu_{i} , viv_{i} , lil_{i} ( 1<=ui,vi<=n1<=u_{i},v_{i}<=n , 1<=li<=1091<=l_{i}<=10^{9} ) — the numbers of towns connected by the ii -th road and the length of the ii -th road. No road connects a town to itself, no two roads connect the same towns.

It's guaranteed that it's always possible to close down one of the roads so that all the towns are still reachable from each other.

输出格式

Print a single integer — the minimum possible inconvenience of the roads after the refusal from one of the roads.

输入输出样例

  • 输入#1

    3
    1 2 4
    2 3 5
    1 3 1
    

    输出#1

    5
    
  • 输入#2

    5
    2 3 7
    3 1 9
    4 1 8
    3 5 4
    4 5 5
    

    输出#2

    18
    
首页