#P3479. Fire Extinguisher Placement
Fire Extinguisher Placement
Fire Extinguisher Placement
Byteasar has built a new palace with n chambers and n-1 corridors. The corridors connect the chambers so that they form a tree, with chamber 1 being the unique entrance. The fire marshal requires that fire extinguishers be placed in some of the chambers. The rules are as follows:
- Fire extinguishers can be placed in any chambers; a chamber may store any number of them.
- Every chamber must be assigned one extinguisher (which may be stored in a different chamber).
- Each extinguisher can be assigned to at most
S
chambers. - For every chamber, its assigned extinguisher must be within K corridors (i.e. the distance in the tree is at most
K
).
Byteasar wants to use the minimum number of extinguishers to meet these requirements. Given the structure of the palace, your task is to determine that minimum number.
Note: Any formulas should be formatted in LaTeX. For example, the number of chambers is given by $n$, the capacity of each extinguisher is $S$, and the maximum allowed distance is $K$.
inputFormat
The first line contains three integers: n
($1 \le n \le 10^5$), S
and K
, where $n$ is the number of chambers, $S$ is the maximum number of chambers that one extinguisher can be assigned to, and $K$ is the maximum allowed distance (in number of corridors).
Each of the next n-1
lines contains two integers u
and v
($1 \le u,v \le n$) describing a corridor connecting chamber u
and chamber v
. It is guaranteed that the palace forms a tree with chamber 1 as the entrance and that every chamber is reachable by exactly one simple path from chamber 1.
outputFormat
Output a single integer, the minimum number of fire extinguishers needed.
sample
3 1 1
1 2
1 3
3