Note: This is an approximate problem. There is no exact solution. You must find the most optimal solution. Please, take a look at the sample explanation to ensure that you understand the problem correctly.
Problem statement
Given an undirected graph of N nodes and M edges. Every node has a weight attached to it denoted by an array W.
Select a subset of nodes say S, such that for every edge (u,v) in the above graph there exists either u or v in the subset S.
Let's define weight of set S as X = |S|×∑W[i], where i denotes all the nodes present in the subset S and |S| denotes size of subset.
Aim is to minimize X.
Note:
Input format :
Output format :
Verdict and scoring :
Your score is equal to the sum of the values of all test files. The value of each test file is equal to the value of X that you found.
If the subset is invalid you will receive a wrong answer verdict.
Constraints :
1≤N,M≤1051≤W[i]≤105