
Fax McClad, Croneria's most innovative bounty hunter, has been assigned by the Cronerian government to set up a Christmas tree.
Fax is given
Fax needs to connect the tree pieces such that all of the tree pieces form a complete tree. In a complete tree, there is exactly one path between any two tree pieces. Each connection that Fax makes has a length of
There are two types of trees that Fax can build, which is signified by
Can you help Fax to determine what the height of his tree will be?
Constraints
Subtask | Points | |||
---|---|---|---|---|
1 | 5 | |||
2 | 10 | |||
3 | 15 | No additional constraints | ||
4 | 25 | No additional constraints | ||
5 | 45 | No additional constraints |
Input Specification
The first line of input will contain three space-separated integers,
Output Specification
Output a single integer, the maximum height of the tree if
Sample Input 1
4 2 1
1 2 4
1 3 6
Sample Output 1
11
Explanation for Sample Output 1
One possible solution is to let piece
Sample Input 2
4 2 2
1 2 4
1 3 6
Sample Output 2
6
Explanation for Sample Output 2
One possible solution is to let piece
Comments
https://codeforces.com/blog/entry/17974
This comment is hidden due to too much negative feedback. Show it anyway.
Clearly the problems aren't the same since you solved Dreaming but not this (during the contest).
Should tree be just the binary tree? Or any type of tree is acceptable?
Any type of tree is acceptable.