1. 程式人生 > >【Codeforces Round 364 (Div 2)E】【樹上路徑 貪心】Connecting Universities 樹上2k個點配對使得路徑之和儘可能大

【Codeforces Round 364 (Div 2)E】【樹上路徑 貪心】Connecting Universities 樹上2k個點配對使得路徑之和儘可能大

Treeland is a country in which there arentowns connected byn - 1two-way road such that it's possible to get from any town to any other town.

In Treeland there are2kuniversities which are located in different towns.

Recently, the president signed the decree to connect universities by high-speed network.The Ministry of Education understood the decree in its own way and decided that it was enough to connect each university with another one by using a cable. Formally, the decree will be done!

To have the maximum sum in the budget, the Ministry decided to divide universities into pairs so that the total length of the required cable will be maximum. In other words, the total distance between universities inkpairs should be as large as possible.

Help the Ministry to find the maximum total distance. Of course, each university should be present in only one pair. Consider that all roads have the same length which is equal to1

.