Coding Test
Time limit2.5sMemory limit1024 MB
Given A[i] fixed problems per level and B[i] ambiguous problems that can go to level i or i+1, find the maximum number of full sets for each firm's range [L, U].
- Level
Medium7 of 10
- Topics
- Prefix sum, Greedy
- Solved
- No attempts yet
Problem
Coding tests have grown popular, and a company now makes problems for them and sells the problems to IT companies.
For convenience, the company divides the difficulty of its problems into levels from to . The company currently has problems rated at difficulty level . It also has problems rated at either level or level , because the rating is ambiguous. No problems are rated in any other way.
The company is now looking for firms to sell problems to. A total of firms have shown interest, numbered from to . Firm () is only interested in problems with difficulty at least and at most .
When selling to firm , the company wants to sell one problem of each difficulty from to as a bundle. Call this bundle a set.
If the company sells problems only to firm , what is the maximum number of sets it can sell?
A problem rated at either level or level can be assigned to one of the two levels, so that the number of sets sold is as large as possible. No problem may appear more than once across all the sets sold.
Constraints
- for all
- for all
- for all