Company: MediaNet_1sep
Difficulty: medium
Root It Problem Description You are given a tree with A vertices. At each vertex, some number of candies are placed. Vertex i contains B[i] candies, given in the input. You are also given a 2-D array C which denotes that there is an undirected edge between C[i][0] and C[i][1]. You have to choose a starting vertex in the beginning or a root, and you are only permitted to move from vertex to vertex only if an edge connects them. You are not allowed to visit any visited vertex again. For every possible selection of the of the tree, you write the value of Maximum candies you can obtain - Minimum candies you can obtain using the same root, in your notebook. Note: While traversing the tree, you can stop at any vertex you want. In other words, it is not necessary to start from the root and end in a leaf. You have to tell the maximum of all the values written in the notebook. Input Format The first argument is the integer A. The second argument is an integer array B. The third argument is an 2