Maximum GPU Tasks with Credit Regeneration

Maximum 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.
PythonGreedyPriority QueueSortingToken Bucket
00
Read
1
InterviewGPT

AI-powered tools to help you succeed in tech interviews — from resume to offer.

Products

  • Interview Solver
  • Question Bank
  • Golden Blogs
  • Intervipedia
  • Application Tools

Company

  • Pricing
  • FAQ
  • About

Legal

  • Privacy Policy
  • Terms of Service

© 2026 InterviewGPT Inc. All rights reserved.

All systems operationalUS-East

Made with ♥ for developers