#K89052. Minimum Number of Trips to Deliver Supplies

    ID: 37444 Type: Default 1000ms 256MiB

Minimum Number of Trips to Deliver Supplies

Minimum Number of Trips to Deliver Supplies

You are given a tree representing a network of cities connected by bidirectional roads. The capital is city 1, and every other city can be reached via these roads. Each road has an associated travel time. A truck that carries supplies can travel a maximum distance of (x) units in a single trip. Your task is to determine the minimum number of trips required to deliver supplies from the capital to every city, assuming that in one trip the truck can go as far as (x) time units before needing to start another trip. In other words, you must compute (\lceil\frac{D}{x}\rceil), where (D) is the maximum distance from the capital to any city.

inputFormat

The first line contains two integers (n) and (x) ((2 \leq n \leq 10^5), (1 \leq x \leq 10^9)), where (n) is the number of cities and (x) is the maximum distance the truck can travel in one trip. The second line contains a single integer (m) representing the number of roads (in a tree, (m = n - 1)). Each of the next (m) lines contains three integers (u), (v), and (t) ((1 \leq u,v \leq n), (1 \leq t \leq 10^9)), indicating there is a road between cities (u) and (v) with travel time (t).

outputFormat

Output a single integer, the minimum number of trips required to deliver supplies to all cities.## sample

5 10
4
1 2 5
1 3 3
3 4 7
4 5 2
2

</p>