Company: Meesho_17july
Difficulty: medium
Seat booking Problem Description You are given an integer N denoting the number of seats in a cinema hall numbered from 1 to N. There are M groups where B[i] denotes the number of persons in the i th group. The persons from the same group want to sit together. If there are B[i] persons in the i th group then they would prefer to sit from L to R such that R-L+1=B[i]. A[i] denotes the cost of the i th seat ticket. You have to help the cinema hall owner make the maximum possible profit by assigning the seats to the groups optimally. Calculate the maximum profit the cinema hall owner can make through an optimal seating arrangement. Function description Complete the function solve() which takes 4 parameters. This function takes the following parameters and returns the required answer: N: Represents the number of seats in the cinema hall M: Represents the number of groups visiting the cinema hall A: Represents the array A, where A[i] represents the cost of the i th seat ticket B: Represents