Tap here to switch tabs
Problem
Submissions

Problem: Minimize Maximum Component Cost

Try to solve the Minimize Maximum Component Cost problem.

Statement

You are given an integer n representing the number of vertices in an undirected connected graph, with vertices labeled from 00 to n −1- 1. You are also given a two dimensional integer array edges, where edges[i] = [u_i, v_i, w_i] denotes an undirected edge between vertices u_i and v_i with weight w_i, and an integer k.

You can remove any number of edges from the graph to split it into at most k connected components. The cost of a connected component is defined as the maximum weight of any edge present in that component, or 00 if the component contains no edges.

Return the minimum possible maximum cost among all components after splitting the graph into at most k connected components.

Constraints:

  • 1≤1 \leq n ≤5×104\leq 5 \times 10^4

  • 0≤0 \leq edges.length ≤105\leq 10^5

  • edges[i].length =3= 3

  • 0≤0 \leq u_i, v_i << n

  • 1≤1 \leq w_i ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq n

  • The input graph is connected.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimize Maximum Component Cost

Try to solve the Minimize Maximum Component Cost problem.

Statement

You are given an integer n representing the number of vertices in an undirected connected graph, with vertices labeled from 00 to n −1- 1. You are also given a two dimensional integer array edges, where edges[i] = [u_i, v_i, w_i] denotes an undirected edge between vertices u_i and v_i with weight w_i, and an integer k.

You can remove any number of edges from the graph to split it into at most k connected components. The cost of a connected component is defined as the maximum weight of any edge present in that component, or 00 if the component contains no edges.

Return the minimum possible maximum cost among all components after splitting the graph into at most k connected components.

Constraints:

  • 1≤1 \leq n ≤5×104\leq 5 \times 10^4

  • 0≤0 \leq edges.length ≤105\leq 10^5

  • edges[i].length =3= 3

  • 0≤0 \leq u_i, v_i << n

  • 1≤1 \leq w_i ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq n

  • The input graph is connected.