#C6692. Consecutive Activity Execution
Consecutive Activity Execution
Consecutive Activity Execution
A robot is assigned a sequence of activities, each consuming a specific amount of battery energy. The robot starts with an initial battery capacity (B) and must perform activities consecutively. Your task is to determine the maximum number of consecutive activities the robot can perform without the total energy consumption exceeding (B). In other words, given an array (A) of length (N) where each element represents the energy consumption of an activity, find the maximum length (k) such that there exists an index (i) for which (\sum_{j=i}^{i+k-1} A_j \le B). This problem can be efficiently solved using a sliding window technique.
inputFormat
Input is read from standard input (stdin) as follows:
- The first line contains an integer (T), the number of test cases.
- For each test case, the first line contains two integers (N) and (B), where (N) is the number of activities and (B) is the initial battery capacity.
- The second line for each test case contains (N) space-separated integers representing the energy consumption of each activity.
outputFormat
For each test case, output a single integer on a new line to standard output (stdout) representing the maximum number of consecutive activities that the robot can perform without exceeding the battery capacity.## sample
2
5 100
20 30 50 10 40
3 60
10 20 30
3
3
</p>