Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using Java and priority queues to solve this problem with a complexity of O(log N) (2) Sean is a big fan of Coldplay, which is
Using Java and priority queues to solve this problem with a complexity of O(log N)
(2) Sean is a big fan of Coldplay, which is a British rock band. Coldplay is in New York City for their "A Head Full of Dreams Tour". They will perform in the MetLife Stadium. So, Sean decided to go and watch his favorite band perform. After reaching the stadium, he saw that many people have lined up for the concert 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 dollars. Now, every fan standing in the line will get a ticket one by one. Given the seating capacities of different rows, find the maximum possible amount that the concert event will gain with the help of the ticket sales Input The first line consists of M and N. M denotes the number of seating rows in the stadium and N denotes the number of Coldplay 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. XIM] where Xi] denotes the number of empty seats initially in the ith row Output: Print in a single line the maximum dollars the concert event will gain Constraints: 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started