Question: Please Write C code: With the IPL going on, the Sharjah Cricket Stadium management is trying to figure out the optimal strategy for ticket sales.*

Please Write C code:

With the IPL going on, the Sharjah Cricket Stadium management is trying

to figure out the optimal strategy for ticket sales.* There are M

With the IPL going on, the Sharjah Cricket Stadium management is trying to figure out the optimal strategy for ticket sales.* 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 dollars that the stadium 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 football fans waiting in the line to get a ticket for the match. Next line consists of M space separated integers X[1,X[21,X[31. X[M] where X[i] denotes the number of empty seats initially in the ith row. Output: Print in a single line the maximum dollars the stadium stands to gain. Constraints: 1

Step by Step Solution

3.34 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include include int main printfSample Input int mn m numb... View full answer

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 Algorithms Questions!