Question: code in java and take input from a in2.txt (2) John's favorite game is Football and his favorite club is Manchester United. Manchester United has

code in java and take input from a in2.txt

code in java and take input from a in2.txt (2) John's favorite

(2) John's favorite game is Football and his favorite club is "Manchester United". Manchester United has qualified for the Champions League Final which is to be held at the Wembley Stadium in London. So, he decided to go there and watch his favorite team play. After reaching the stadium, he saw that many people have lined up for the match tickets. He knows that there are M rows in the stadium with different seating capacities. They may or may not be equal. The price of the ticket depends on the row. If the row has K (always greater than 0) vacant seats, then the price of the ticket will be K pounds (units of British Currency). Now, every football fan standing in the line will get a ticket one by one Given the seating capacities of different rows, find the maximum possible pounds that the club will gain with the help of the ticket sales. Write code for your own Heap data structure to solve this problem. Input: Thake input from a file in2.txt. The first line consists of the number of test cases T. For each test case, the first line consists of M and N. M denotes the number of seating rows in the stadium and N denotes the number of football fans waiting in the line to get a ticket for the match. Next line consists of M space separated integers X[1],X[2],X[3] X[M] where X[i] denotes the number of empty seats initially in the ith row Output Print in a single line the maximum pounds the club will gain Constraints: 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!