Stage Lighting
Time limit2sMemory limit512 MB
For each start i, find the smallest r such that some subset of projectors i to r, with pairwise disjoint connector sets, has total power at least Z.
- Level
Hard8 of 10
- Topics
- Sliding window, Bit manipulation, Dynamic programming
- Solved
- No attempts yet
Problem
projectors are installed along a stage, numbered from 1 to from left to right. Projector has power . The stage counts as lit if the total power of the switched-on projectors is at least .
Each working projector must be connected to a set of connectors. There are different connectors in total. Projector has outputs and must be connected to connectors . At any moment, at most one projector can be connected to a given connector.
For each from 1 to , find the minimum such that, among projectors numbered from to inclusive, you can choose a subset of projectors to run at the same time so that the stage is lit.
Input
The first line contains three integers , , and (, , ). The second line contains integers (). The next lines describe the connectors. Line contains () followed by distinct integers ().
Output
Print lines. On line , print if it exists, and otherwise.