Company: Barclays
Difficulty: medium
Team Power Programming Language: C++14 A random game is being played in teams by N kids, each with strength Xi. The kids stand in a line with the first kid at position 1, the second at 2, and so on. A person draws M cards randomly from a box, each card containing a pair of numbers that represents the position of kids belonging to the same team. For example, if a card contains [1, 4] and another contains [4, 3], then the kids at positions [1, 4, 3] belong to the same team. The kids whose positions do not come up on any of the cards participate as one-person teams. Each team\'s power is determined by the sum of the strengths of the kids on the team. The team with the highest power wins. Design an algorithm that outputs the power of the winning team. Input Format The first line of the input consists of an integer - num , representing the number of kids (N). The second line consists of N space-separated integers, representing the kids\' strength. The third line input consists of two space-