You are given a weighted array that contains N elements and a graph with N vertices and M edges. Determine a valid assignment of weights to vertices such that the value of E is maximum.
Here, E denotes the summation over all edges max (weight[u], weight[v]) and (u, v) belongs to M.
The assignment of weights must be valid by considering the following points:
Input format
Output format
Print N elements where the ith element is the value of weight assigned to vertex i.
Constraints
1≤N≤1e51≤M≤1e50≤Weight[]≤1e6
Weight assignment is valid.
Edge (1,2) , max (weight[1],weight[2]) = 10
Edge (2,3) , max (weight[2],weight[3]) = 20
Edge (3,4) , max (weight[3],weight[4]) = 20
Edge (2,4) , max (weight[2],weight[4]) = 3
E = 10 + 20 + 20 + 3 = 53