Microsoft Online Assessment Question
Anonymous User
2980

Seat Booking

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 ith group. The persons from same group want to sit together, if there are B[i] persons in the ith 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 ith seat ticket. you have to help the cinema hall owner in making the maximum possible profit by assigning the seats to the groups in an optimal manner.

Constraints
1 <= N<= 500
1 <= M <= 13
1 <= Ai<= 10^9
1 <= Bi <= N
B1 + B2 + B3 + ..... + Bm <= N

Sample Input
N = 6
M = 2
A = [1, 7, 8, 2, 3, 9]
B = [2, 1]

Sample Output
24

Comments (18)