The Question
CodingMaximum GPU Tasks with Credit Regeneration
You are managing a GPU cluster that uses a credit-based system for job execution. You start with
initial_credits and a max_capacity. Credits regenerate at a constant regeneration_rate per unit of time. You are given a list of tasks, where each task is [timestamp, cost]. A task can only be executed if your current credit balance is at least equal to the task's cost at that timestamp. If you choose to execute a task, the cost is immediately deducted from your balance. If you cannot afford a task, you may choose to 'undo' a previously executed task to reclaim its credits (though the time spent is not recovered). Determine the maximum number of tasks you can complete given the task schedule. Assume for this optimization that reclaiming credits from a past task ignores the capacity limit for the reclaimed amount.Python
Greedy
Priority Queue
Sorting
Token Bucket