Get Max Programs
Within an Amazon software management tool, there's a collection of software programs and time slots. Each time slot lasts k seconds, and within that time the slots do not overlap. The software programs are required to sequentially from 1 to n, and cannot be interrupted. Each program has a specific execution time denoted as time[i].
The objective is to execute the software programs following a specific algorithm:
The goal is to determine the maximum number of software programs that can be executed using this algorithm. This can be done by moving to the last program executed within the set of software programs and removing the software programs from the leftmost of the list until the remaining set of software programs can be executed with the available time slots.
Find the maximum number of software programs from the suffix that can be executed efficiently using this algorithm. In other words, you are looking for the longest sequence of consecutive software programs from the end of the list that can be successfully scheduled within the given time slots when scheduled according to the rules provided.
Complete the function getMaxPrograms in the editor.
getMaxPrograms has the following parameters:
int time[n]: an array of integers denoting the execution time of software programs.int m: number of time slots availableint k: time length of each time slot
Returns
int: the maximum number of software programs from the suffix that can be executed.
🌷ଓ༉ Many thanks, HxyJxy, Nachos and spike! 🫡
1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
1 ≤ n, m ≤ 2*1051 ≤ k ≤ 1091 <= time[i] <= k/li>