Important Test
InterviewTime limit2sMemory limit512 MB
For each variant, find the longest prefix solvable in t minutes given he may replace at most one task time with t0. Since order is fixed, choose the single task in that prefix whose copying saves the most time.
- Level
Medium4 of 10
- Topics
- Array, Prefix sum, Greedy
- Solved
- No attempts yet
Problem
Nick takes an important test soon. The test has variants, and variant has tasks numbered from 1 to . For every task of every variant Nick has written down the time in minutes that he needs to solve it.
The tasks must be solved in the order they appear in the variant, one after another. The answers must be submitted within the deadline of minutes. Nick thinks about secretly copying a solution from his notes, but he does not want to risk much, so he copies at most one solution. A task whose solution he copies costs minutes instead of its own time.
For each variant, find the largest number of tasks Nick can write down if he gets that variant.
Input
The first line contains three integers , and (, , ): the number of variants, the length of the test, and the time needed to secretly copy one solution from the notes.
Each of the next lines describes one variant. The first integer on the line is the number of tasks () in variant , followed by integers (), the times needed for the tasks.
Output
For each variant print one integer on its own line: the largest number of tasks Nick can write down if he gets that variant.