Back to Practice Dashboard
Competitive ProgrammingEasy

Minimum time to finish jobs

Learn how to solve the 'Minimum time to finish jobs' problem. This detailed resource details brute force and optimized approaches.

Problem Statement

Easy

Write a function min_time_jobs(jobs, k, t) that finds the minimum time to finish all jobs. The array jobs represents the time required to complete each job. There are k assignees, and each assignee takes t units of time to complete 1 unit of job. Jobs can only be assigned as contiguous sub-segments to the assignees.

Constraints
  • 1 <= len(jobs) <= 10^5
  • 1 <= k <= len(jobs)
  • 1 <= t <= 1000
  • 1 <= jobs[i] <= 10^4

Examples

Example 1
Input
min_time_jobs([10, 7, 8, 12, 8, 5, 9], 4, 5)
Output
100
Explanation

Optimal contiguous assignment: [10, 7], [8, 12], [8, 5], [9]. Max job units assigned is 20 (8+12). Time = 20 * 5 = 100.

Example 2
Input
min_time_jobs([4, 5, 10], 2, 1)
Output
10
Explanation

Optimal contiguous assignment: [4, 5], [10]. Max job units assigned is 10. Time = 10 * 1 = 10.

Need a Hint?
Analyze the input constraints. Try sorting first (O(n log n)) or using a hash map/set to track seen elements in O(n) time.
Edge Cases to Watch
  • Empty list or null input variables
  • Single item lists/arrays
  • Extremely large input bounds causing integer or stack overflow

Ready to Solve?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Open in Editor