NOIP '18 P3 - Constructing Tracks

View as PDF

Submit solution

Points: 17 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem types

Given a tree with n vertices. Edge i of the tree has length li. We need to choose m edge-disjoint paths such that the length of the path with minimum length is maximized.

Input Specification

The first line contains two integers n and m denoting the number of vertices and the number of paths to be chosen.

In the following n1 lines, the ith line contains three positive integers ai,bi,li denoting the ith edge goes from ai to bi and has length li.

Output Specification

The output contains an integer denoting the maximum possible minimum length of the m tracks chosen.

Sample Input 1

Copy
7 1
1 2 10
1 3 5
2 4 9
2 5 8
3 6 6
3 7 7

Sample Output 1

Copy
31

Note: the chosen path is the path from vertex 4 to vertex 7.

Sample Input 2

Copy
9 3
1 2 6
2 3 3
3 4 5
4 5 10
6 2 4
7 2 9
8 4 7
9 4 4

Sample Output 2

Copy
15

The chosen paths are the path from vertex 1 to vertex 7, vertex 6 to vertex 9, and vertex 8 to vertex 5.

Additional Samples

Additional samples can be found here.

Constraints

Test Case n m ai=1 bi=ai+1 Degree of vertex 3
1 5 =1 No No Yes
2 10 n1 Yes
3 15 Yes No No
4 1000 =1 No Yes
5 30000 Yes No
6 No
7 n1 Yes
8 50000
9 1000 No Yes Yes
10 30000
11 50000
12 50 No
13
14 200
15
16 1000
17 No
18 30000
19
20 50000

For all test cases, 2n50000, 1mn1, 1ai,bin, 1li10000.


Comments

There are no comments at the moment.